mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 16:57:40 +00:00
use dict.get in case upload_date does not exist
This commit is contained in:
parent
8d93c21466
commit
0fdbe3146c
1 changed files with 4 additions and 4 deletions
|
@ -66,7 +66,7 @@ class AfreecaTVIE(InfoExtractor):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_video_key(key):
|
def parse_video_key(key):
|
||||||
video_key = {'upload_date': None, 'part': '0'}
|
video_key = {}
|
||||||
m = re.match(r'^(?P<upload_date>\d{8})_\w+_(?P<part>\d+)$', key)
|
m = re.match(r'^(?P<upload_date>\d{8})_\w+_(?P<part>\d+)$', key)
|
||||||
if m:
|
if m:
|
||||||
video_key['upload_date'] = m.group('upload_date')
|
video_key['upload_date'] = m.group('upload_date')
|
||||||
|
@ -92,12 +92,12 @@ class AfreecaTVIE(InfoExtractor):
|
||||||
thumbnail = xpath_text(video_xml, './track/titleImage', 'thumbnail')
|
thumbnail = xpath_text(video_xml, './track/titleImage', 'thumbnail')
|
||||||
|
|
||||||
entries = []
|
entries = []
|
||||||
for video_file in video_xml.findall('./track/video/file'):
|
for i, video_file in enumerate(video_xml.findall('./track/video/file')):
|
||||||
video_key = self.parse_video_key(video_file.get('key'))
|
video_key = self.parse_video_key(video_file.get('key'))
|
||||||
entries.append({
|
entries.append({
|
||||||
'id': '%s_%s' % (video_id, video_key['part']),
|
'id': '%s_%s' % (video_id, video_key.get('part', i + 1)),
|
||||||
'title': title,
|
'title': title,
|
||||||
'upload_date': video_key['upload_date'],
|
'upload_date': video_key.get('upload_date'),
|
||||||
'duration': int_or_none(video_file.get('duration')),
|
'duration': int_or_none(video_file.get('duration')),
|
||||||
'url': video_file.text,
|
'url': video_file.text,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue