From fe75b4e06cbc884517b55a34625bae10decd45cc Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Fri, 1 Dec 2017 22:48:24 +0100 Subject: [PATCH] Use .cast ext and application/x-asciicast media type Closes #224 --- README.md | 2 +- asciinema/asciicast/__init__.py | 10 ++++++---- doc/asciicast-v2.md | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6cfd7b4..5edfe64 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ Playing from HTTP(S) URL: asciinema play http://example.com/demo.cast Playing from asciicast page URL (requires `` in page's HTML): +type="application/x-asciicast" href="/my/ascii.cast">` in page's HTML): asciinema play https://asciinema.org/a/22124 asciinema play http://example.com/blog/post.html diff --git a/asciinema/asciicast/__init__.py b/asciinema/asciicast/__init__.py index 726f9df..84051de 100644 --- a/asciinema/asciicast/__init__.py +++ b/asciinema/asciicast/__init__.py @@ -19,14 +19,16 @@ class Parser(html.parser.HTMLParser): self.url = None def handle_starttag(self, tag, attrs_list): - # look for + # look for if tag == 'link': attrs = {} for k, v in attrs_list: attrs[k] = v - if attrs.get('rel') == 'alternate' and attrs.get('type') == 'application/asciicast+json': - self.url = attrs.get('href') + if attrs.get('rel') == 'alternate': + type = attrs.get('type') + if type == 'application/asciicast+json' or type == 'application/x-asciicast': + self.url = attrs.get('href') def open_url(url): @@ -57,7 +59,7 @@ def open_url(url): url = parser.url if not url: - raise LoadError(""" not found in fetched HTML document""") + raise LoadError(""" not found in fetched HTML document""") return open_url(url) diff --git a/doc/asciicast-v2.md b/doc/asciicast-v2.md index b1a49ec..39fb1cd 100644 --- a/doc/asciicast-v2.md +++ b/doc/asciicast-v2.md @@ -17,6 +17,9 @@ Example file: [6.541828, "o", "Bye!"] ``` +Suggested file extension is `.cast`, suggested media type is +`application/x-asciicast`. + ## Header asciicast header is JSON-encoded object containing recording meta-data.