From da37cc320ae7c5125de33254aaff09fdef49ec86 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Sat, 17 Jun 2017 22:24:08 -0400 Subject: [PATCH 1/2] Create oddshot.py --- youtube_dl/extractor/oddshot.py | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 youtube_dl/extractor/oddshot.py diff --git a/youtube_dl/extractor/oddshot.py b/youtube_dl/extractor/oddshot.py new file mode 100644 index 000000000..3ecdb5d12 --- /dev/null +++ b/youtube_dl/extractor/oddshot.py @@ -0,0 +1,49 @@ +import re +from .common import InfoExtractor +from youtube_dl.utils import compat_str + +class OddshotIE(InfoExtractor): + _VALID_URL = r'(?:https?://)?(?:www\.)?oddshot\.tv/s(hot)?(/.+)?/(?P.+)' + _TESTS = [ + { + 'url': 'https://oddshot.tv/s/TAUv5m', + 'md5': '1a927556df771148d20657120f096af5', + 'info_dict': { + 'id': 'UzoKaNE4KaNBtJu8zTVvomJd', + 'ext': 'mp4', + 'title': 'pozamiatane', + 'description': 'Twitch - Counter-Strike: Global Offensive - izakooo' + } + }, + { + 'url': 'https://oddshot.tv/s/TAUv5m', + 'md5': '0553b234670be27d96da10066fabc052', + 'info_dict': { + 'id': 'TAUv5m', + 'ext': 'mp4', + 'title': 'ELEAGUE CLASH FOR CASH CS:GO THE REMATCH', + 'description': 'Youtube - ELEAGUE' + } + } + ] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + # Using compat_str for running test : if not isinstance(info_dict['id'], compat_str): YoutubeDL.py l1235 + video_id = compat_str(mobj.group('id')) + # Default User-Agent not working, but working with curl User-Agent + webpage = self._download_webpage(url,video_id,headers={'User-Agent':'curl/7.8 (i386-redhat-linux-gnu) libcurl 7.8 (OpenSSL 0.9.6b) (ipv6 enabled)'}) + self.report_extraction(video_id) + # Perhaps a proper way with helpers but 'data-react-helmet="true"' ruins + title = self._html_search_regex(r'property="og:title" content="(.+?)"', webpage, u'video Title') + url = self._html_search_regex(r'property="og:video:secure_url" content="(.+?)"', webpage, u'video URL') + url = re.sub("\.mp4(#t.+)?$", ".mp4", url) + description = self._html_search_regex(r'property="og:description" content="(.+?)"', webpage, u'video Description') + thumbnail = self._html_search_regex(r'property="og:image" content="(.+?)"', webpage, u'video Thumbnail') + return { + 'id': video_id, + 'url': url, + 'description': description, + 'title': title, + 'thumbnail': thumbnail + } From cb976711718ed61b1cc1fc21eefdcff19e017af2 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Sat, 17 Jun 2017 22:25:09 -0400 Subject: [PATCH 2/2] Add Oddshot extractor --- youtube_dl/extractor/extractors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 7e45232dd..020d09d72 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -724,6 +724,7 @@ from .nytimes import ( from .nuvid import NuvidIE from .nzz import NZZIE from .odatv import OdaTVIE +from .oddshot import OddshotIE from .odnoklassniki import OdnoklassnikiIE from .oktoberfesttv import OktoberfestTVIE from .ondemandkorea import OnDemandKoreaIE