Open geeseven opened 5 years ago
I think it would be helpful to have examples of all the possible Twitch URLs.
I am currently using the following regex:
https?://(clips\.|www\.|m\.)?twitch\.tv/[^.]+$
Looking over the current Twitch extractor for youtube-dl, looks like we would also need to add the go
and player
subdomains.
Given #696, it does not make sense to submit a pull request. For anyone interested, here is what I did:
$ git diff rtv/mime_parsers.py
diff --git a/rtv/mime_parsers.py b/rtv/mime_parsers.py
index 9d7eae8..3a51444 100644
--- a/rtv/mime_parsers.py
+++ b/rtv/mime_parsers.py
@@ -320,6 +320,17 @@ class StreamableMIMEParser(OpenGraphMIMEParser):
"""
pattern = re.compile(r'https?://(www\.)?streamable\.com/[^.]+$')
+class TwitchMIMEParser(BaseMIMEParser):
+ """
+ Twitch videos can be streamed with vlc or downloaded with youtube-dl.
+ Assign a custom mime-type so they can be referenced in mailcap.
+ """
+ pattern = re.compile(r'https?://(clips|go|m|player|www)\.?twitch\.tv/[^.]+$')
+
+ @staticmethod
+ def get_mimetype(url):
+ return url, 'video/x-youtube'
+
class LiveleakMIMEParser(BaseMIMEParser):
"""
@@ -479,6 +490,7 @@ parsers = [
GiphyMIMEParser,
ImgflipMIMEParser,
LivememeMIMEParser,
+ TwitchMIMEParser,
MakeamemeMIMEParser,
WorldStarHipHopMIMEParser,
GifvMIMEParser,
Is your feature request related to a problem? Please describe. Twitch streams or clips act differently than other video links as they can only be opened in a browser.
Describe the solution you'd like It would be nice to launch mpv or vlc for Twitch streams or clips.
Describe alternatives you've considered Copy/paste is a workaround.
Additional context Seeing that youtube-dl has support for Twitch, I have a working branch that uses 'video/x-youtube' like Vimeo. I would be more than happy to make a pull request.