X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fyam.py;h=63bbc06346a04b385c722eaae22d0ff5c41445f4;hb=e9fb6a4bbee2eaf068a4499ce8fa4df89458a3c3;hp=19ad74d04f32f0a9819af61b01254e4af8a849a5;hpb=602814adab97d605d1fe84d6439c33325dba15c7;p=youtube-dl diff --git a/youtube_dl/extractor/yam.py b/youtube_dl/extractor/yam.py index 19ad74d04..63bbc0634 100644 --- a/youtube_dl/extractor/yam.py +++ b/youtube_dl/extractor/yam.py @@ -9,11 +9,13 @@ from ..utils import ( float_or_none, month_by_abbreviation, ExtractorError, + get_element_by_attribute, ) class YamIE(InfoExtractor): - _VALID_URL = r'http://mymedia.yam.com/m/(?P\d+)' + IE_DESC = '蕃薯藤yam天空部落' + _VALID_URL = r'https?://mymedia.yam.com/m/(?P\d+)' _TESTS = [{ # An audio hosted on Yam @@ -23,6 +25,7 @@ class YamIE(InfoExtractor): 'id': '2283921', 'ext': 'mp3', 'title': '發現 - 趙薇 京華煙雲主題曲', + 'description': '發現 - 趙薇 京華煙雲主題曲', 'uploader_id': 'princekt', 'upload_date': '20080807', 'duration': 313.0, @@ -39,7 +42,8 @@ class YamIE(InfoExtractor): 'description': 'md5:11e2e405311633ace874f2e6226c8b17', 'uploader_id': '2323agoy', 'title': '20090412陽明山二子坪-1', - } + }, + 'skip': 'Video does not exist', }, { 'url': 'http://mymedia.yam.com/m/3598173', 'info_dict': { @@ -54,6 +58,17 @@ class YamIE(InfoExtractor): 'ext': 'mp4', }, 'skip': 'invalid YouTube URL', + }, { + 'url': 'http://mymedia.yam.com/m/2373534', + 'md5': '7ff74b91b7a817269d83796f8c5890b1', + 'info_dict': { + 'id': '2373534', + 'ext': 'mp3', + 'title': '林俊傑&蔡卓妍-小酒窩', + 'description': 'md5:904003395a0fcce6cfb25028ff468420', + 'upload_date': '20080928', + 'uploader_id': 'onliner2', + } }] def _real_extract(self, url): @@ -74,15 +89,19 @@ class YamIE(InfoExtractor): if youtube_url: return self.url_result(youtube_url, 'Youtube') + title = self._html_search_regex( + r']+class="heading"[^>]*>\s*(.+)\s*', page, 'title') + api_page = self._download_webpage( 'http://mymedia.yam.com/api/a/?pID=' + video_id, video_id, note='Downloading API page') api_result_obj = compat_urlparse.parse_qs(api_page) + info_table = get_element_by_attribute('class', 'info', page) uploader_id = self._html_search_regex( - r':[\n ]+(?P[A-Z][a-z]{2}) ' + + r':[\n ]+(?P[A-Z][a-z]{2})\s+' + r'(?P\d{1,2}), (?P\d{4})', page) if mobj: upload_date = '%s%02d%02d' % ( @@ -96,7 +115,8 @@ class YamIE(InfoExtractor): return { 'id': video_id, 'url': api_result_obj['mp3file'][0], - 'title': self._html_search_meta('description', page), + 'title': title, + 'description': self._html_search_meta('description', page), 'duration': duration, 'uploader_id': uploader_id, 'upload_date': upload_date,