1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-03-10 08:07:25 +08:00

cleaned up code

This commit is contained in:
Julian Galperin 2019-04-19 10:25:04 -04:00
parent eeb17b9979
commit 75be8e5e25

View File

@ -19,6 +19,7 @@ class ChangbaIE(InfoExtractor):
'id': '1146278955', 'id': '1146278955',
'ext': 'mp4', 'ext': 'mp4',
'title': ' ', 'title': ' ',
'vcodec': None
} }
}, { }, {
'url': 'http://changba.com/s/nZqfbS_vCnieNNjJ7UiEGw?', 'url': 'http://changba.com/s/nZqfbS_vCnieNNjJ7UiEGw?',
@ -27,23 +28,24 @@ class ChangbaIE(InfoExtractor):
'id': '1091968526', 'id': '1091968526',
'ext': 'mp3', 'ext': 'mp3',
'title': '下雪 ', 'title': '下雪 ',
'vcodec': 'none'
} }
}] }]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
# print(webpage)
id = self._search_regex(r'workid=([0-9]+)', webpage, 'id') id = self._search_regex(r'workid=([0-9]+)', webpage, 'id')
title = self._search_regex( title = self._search_regex(
r'<div[^>]+class="title"[^>]*>([^<]+)', webpage, 'title' r'<div[^>]+class="title"[^>]*>([^<]+)', webpage, 'title'
) )
print(title)
# title = self._og_search_title(webpage)
ext = None ext = None
vcodec = None
try: try:
src_url = self._search_regex(r'var a="([^"]*)', webpage, 'url') src_url = self._search_regex(r'var a="([^"]*)', webpage, 'url')
ext = 'mp3' ext = 'mp3'
vcodec = 'none'
except RegexNotFoundError: except RegexNotFoundError:
encoded = self._search_regex( encoded = self._search_regex(
r'video_url: \'([0-9A-Za-z]+=*)', webpage, 'video url' r'video_url: \'([0-9A-Za-z]+=*)', webpage, 'video url'
@ -51,10 +53,10 @@ class ChangbaIE(InfoExtractor):
src_url = base64.b64decode(encoded).decode('utf-8') src_url = base64.b64decode(encoded).decode('utf-8')
ext = 'mp4' ext = 'mp4'
return { return {
'url': src_url, 'url': src_url,
'id': id, 'id': id,
'ext': ext, 'ext': ext,
'title': title, 'title': title,
'vcodec': vcodec
} }