aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPeter Rowlands <peter@pmrowla.com>2016-05-08 08:56:22 +0900
committerPeter Rowlands <peter@pmrowla.com>2016-05-08 08:56:22 +0900
commit0fdbe3146c2b3825cc26aca7e918df041b0f9adf (patch)
tree0dcffa35c9ec7ae618bb830995279a7b95c72472 /youtube_dl
parent8d93c214664e5442320a20e899123b8bfd51cd08 (diff)
use dict.get in case upload_date does not exist
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/extractor/afreecatv.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/youtube_dl/extractor/afreecatv.py b/youtube_dl/extractor/afreecatv.py
index aa5847677..4ebc61bae 100644
--- a/youtube_dl/extractor/afreecatv.py
+++ b/youtube_dl/extractor/afreecatv.py
@@ -66,7 +66,7 @@ class AfreecaTVIE(InfoExtractor):
@staticmethod
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)
if m:
video_key['upload_date'] = m.group('upload_date')
@@ -92,12 +92,12 @@ class AfreecaTVIE(InfoExtractor):
thumbnail = xpath_text(video_xml, './track/titleImage', 'thumbnail')
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'))
entries.append({
- 'id': '%s_%s' % (video_id, video_key['part']),
+ 'id': '%s_%s' % (video_id, video_key.get('part', i + 1)),
'title': title,
- 'upload_date': video_key['upload_date'],
+ 'upload_date': video_key.get('upload_date'),
'duration': int_or_none(video_file.get('duration')),
'url': video_file.text,
})