mirror of
https://github.com/l1ving/youtube-dl
synced 2025-01-24 17:56:07 +08:00
50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
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<id>.+)'
|
|
_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
|
|
}
|