]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/yam.py
b294767c5b6bc5a7ec918e9108cc4cff1a5fac40
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_urlparse
10 month_by_abbreviation
,
14 class YamIE(InfoExtractor
):
15 _VALID_URL
= r
'http://mymedia.yam.com/m/(?P<id>\d+)'
18 # An audio hosted on Yam
19 'url': 'http://mymedia.yam.com/m/2283921',
20 'md5': 'c011b8e262a52d5473d9c2e3c9963b9c',
24 'title': '發現 - 趙薇 京華煙雲主題曲',
25 'uploader_id': 'princekt',
26 'upload_date': '20080807',
30 # An external video hosted on YouTube
31 'url': 'http://mymedia.yam.com/m/3598173',
32 'md5': '0238ceec479c654e8c2f1223755bf3e9',
36 'upload_date': '20150202',
37 'uploader': '新莊社大瑜伽社',
38 'description': 'md5:f5cc72f0baf259a70fb731654b0d2eff',
39 'uploader_id': '2323agoy',
40 'title': '外婆的澎湖灣KTV-潘安邦',
44 def _real_extract(self
, url
):
45 video_id
= self
._match
_id
(url
)
46 page
= self
._download
_webpage
(url
, video_id
)
48 # Is it hosted externally on YouTube?
49 youtube_url
= self
._html
_search
_regex
(
50 r
'<embed src="(http://www.youtube.com/[^"]+)"',
51 page
, 'YouTube url', default
=None)
53 return self
.url_result(youtube_url
, 'Youtube')
55 api_page
= self
._download
_webpage
(
56 'http://mymedia.yam.com/api/a/?pID=' + video_id
, video_id
,
57 note
='Downloading API page')
58 api_result_obj
= compat_urlparse
.parse_qs(api_page
)
60 uploader_id
= self
._html
_search
_regex
(
61 r
'<!-- 發表作者 -->:[\n ]+<a href="/([a-z]+)"',
62 page
, 'uploader id', fatal
=False)
63 mobj
= re
.search(r
'<!-- 發表於 -->(?P<mon>[A-Z][a-z]{2}) ' +
64 r
'(?P<day>\d{1,2}), (?P<year>\d{4})', page
)
66 upload_date
= '%s%02d%02d' % (
68 month_by_abbreviation(mobj
.group('mon')),
69 int(mobj
.group('day')))
72 duration
= float_or_none(api_result_obj
['totaltime'][0], scale
=1000)
76 'url': api_result_obj
['mp3file'][0],
77 'title': self
._html
_search
_meta
('description', page
),
79 'uploader_id': uploader_id
,
80 'upload_date': upload_date
,