X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fyam.py;h=19f8762ae57e814a11f868be1a008e21bbaf8efc;hb=b0872c19ea6fb5dcc20d695d6faead4af42da364;hp=511c8b67c0cfb3b32e05156b83fc2f30dad08064;hpb=7105440cecf82aff295df4f32575f6c8b64b3c2d;p=youtube-dl.git
diff --git a/youtube_dl/extractor/yam.py b/youtube_dl/extractor/yam.py
index 511c8b67c..19f8762ae 100644
--- a/youtube_dl/extractor/yam.py
+++ b/youtube_dl/extractor/yam.py
@@ -1,10 +1,15 @@
# coding: utf-8
from __future__ import unicode_literals
+import re
+
from .common import InfoExtractor
from ..compat import compat_urlparse
-from ..utils import month_by_abbreviation
-import re
+from ..utils import (
+ float_or_none,
+ month_by_abbreviation,
+ ExtractorError,
+)
class YamIE(InfoExtractor):
@@ -24,22 +29,44 @@ class YamIE(InfoExtractor):
}
}, {
# An external video hosted on YouTube
- 'url': 'http://mymedia.yam.com/m/3598173',
- 'md5': '0238ceec479c654e8c2f1223755bf3e9',
+ 'url': 'http://mymedia.yam.com/m/3599430',
+ 'md5': '03127cf10d8f35d120a9e8e52e3b17c6',
'info_dict': {
- 'id': 'pJ2Deys283c',
+ 'id': 'CNpEoQlrIgA',
'ext': 'mp4',
- 'upload_date': '20150202',
+ 'upload_date': '20150306',
'uploader': 'æ°è社大ç伽社',
- 'description': 'md5:f5cc72f0baf259a70fb731654b0d2eff',
+ 'description': 'md5:11e2e405311633ace874f2e6226c8b17',
'uploader_id': '2323agoy',
- 'title': 'å¤å©çæ¾æ¹ç£KTV-æ½å®é¦',
- }
+ 'title': '20090412é½æå±±äºååª-1',
+ },
+ 'skip': 'Video does not exist',
+ }, {
+ 'url': 'http://mymedia.yam.com/m/3598173',
+ 'info_dict': {
+ 'id': '3598173',
+ 'ext': 'mp4',
+ },
+ 'skip': 'cause Yam system error',
+ }, {
+ 'url': 'http://mymedia.yam.com/m/3599437',
+ 'info_dict': {
+ 'id': '3599437',
+ 'ext': 'mp4',
+ },
+ 'skip': 'invalid YouTube URL',
}]
def _real_extract(self, url):
- media_id = self._match_id(url)
- page = self._download_webpage(url, media_id)
+ video_id = self._match_id(url)
+ page = self._download_webpage(url, video_id)
+
+ # Check for errors
+ system_msg = self._html_search_regex(
+ r'系統è¨æ¯(?:
|\n|\r)*([^<>]+)
', page, 'system message',
+ default=None)
+ if system_msg:
+ raise ExtractorError(system_msg, expected=True)
# Is it hosted externally on YouTube?
youtube_url = self._html_search_regex(
@@ -49,22 +76,29 @@ class YamIE(InfoExtractor):
return self.url_result(youtube_url, 'Youtube')
api_page = self._download_webpage(
- 'http://mymedia.yam.com/api/a/?pID=' + media_id, media_id)
+ 'http://mymedia.yam.com/api/a/?pID=' + video_id, video_id,
+ note='Downloading API page')
api_result_obj = compat_urlparse.parse_qs(api_page)
- author = self._html_search_regex(
- r'ï¼[\n ]+ï¼[\n ]+(?P[A-Z][a-z]{2}) ' +
r'(?P\d{1,2}), (?P\d{4})', page)
- upload_date = '%s%02d%02d' % (mobj.group('year'),
- month_by_abbreviation(mobj.group('mon')),
- int(mobj.group('day')))
+ if mobj:
+ upload_date = '%s%02d%02d' % (
+ mobj.group('year'),
+ month_by_abbreviation(mobj.group('mon')),
+ int(mobj.group('day')))
+ else:
+ upload_date = None
+ duration = float_or_none(api_result_obj['totaltime'][0], scale=1000)
return {
- 'id': media_id,
+ 'id': video_id,
'url': api_result_obj['mp3file'][0],
'title': self._html_search_meta('description', page),
- 'duration': float(api_result_obj['totaltime'][0]) / 1000.0,
- 'uploader_id': author,
+ 'duration': duration,
+ 'uploader_id': uploader_id,
'upload_date': upload_date,
}