projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
22e35ad
)
fix multi_video part naming, add upload_date field
author
Peter Rowlands
<peter@pmrowla.com>
Fri, 6 May 2016 03:07:29 +0000
(12:07 +0900)
committer
Peter Rowlands
<peter@pmrowla.com>
Fri, 6 May 2016 03:07:29 +0000
(12:07 +0900)
youtube_dl/extractor/afreecatv.py
patch
|
blob
|
history
diff --git
a/youtube_dl/extractor/afreecatv.py
b/youtube_dl/extractor/afreecatv.py
index c9a4b73118d99037e90c5c82d89fed53fea23260..e927e4a48f42ee4da5cbcfe386dc91e858709a35 100644
(file)
--- a/
youtube_dl/extractor/afreecatv.py
+++ b/
youtube_dl/extractor/afreecatv.py
@@
-1,6
+1,8
@@
# coding: utf-8
from __future__ import unicode_literals
# coding: utf-8
from __future__ import unicode_literals
+import re
+
from .common import InfoExtractor
from ..compat import (
compat_urllib_parse_urlparse,
from .common import InfoExtractor
from ..compat import (
compat_urllib_parse_urlparse,
@@
-34,6
+36,15
@@
class AfreecaTVIE(InfoExtractor):
}
}
}
}
+ @staticmethod
+ def parse_video_key(key):
+ video_key = {'upload_date': None, 'part': '0'}
+ m = re.match(r'^(?P<upload_date>\d{8})_\w+_(?P<part>\d+)$', key)
+ if m:
+ video_key['upload_date'] = m.group('upload_date')
+ video_key['part'] = m.group('part')
+ return video_key
+
def _real_extract(self, url):
video_id = self._match_id(url)
parsed_url = compat_urllib_parse_urlparse(url)
def _real_extract(self, url):
video_id = self._match_id(url)
parsed_url = compat_urllib_parse_urlparse(url)
@@
-54,9
+65,11
@@
class AfreecaTVIE(InfoExtractor):
entries = []
for video_file in video_xml.findall('./track/video/file'):
entries = []
for video_file in video_xml.findall('./track/video/file'):
+ video_key = self.parse_video_key(video_file.get('key'))
entries.append({
entries.append({
- 'id':
video_file.get('key'
),
+ 'id':
'%s_%s' % (video_id, video_key['part']
),
'title': title,
'title': title,
+ 'upload_date': video_key['upload_date'],
'duration': int_or_none(video_file.get('duration')),
'url': video_file.text,
})
'duration': int_or_none(video_file.get('duration')),
'url': video_file.text,
})
@@
-75,6
+88,7
@@
class AfreecaTVIE(InfoExtractor):
info['entries'] = entries
elif len(entries) == 1:
info['url'] = entries[0]['url']
info['entries'] = entries
elif len(entries) == 1:
info['url'] = entries[0]['url']
+ info['upload_date'] = entries[0]['upload_date']
else:
raise ExtractorError(
'No files found for the specified AfreecaTV video, either'
else:
raise ExtractorError(
'No files found for the specified AfreecaTV video, either'