1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-01-24 05:42:52 +08:00

OS-portable timestamp calculation

This commit is contained in:
Dimitrios Semitsoglou-Tsiapos 2019-01-28 19:26:26 +01:00
parent cedd5da48c
commit 33b655e19d

View File

@ -39,8 +39,10 @@ class PiaproIE(InfoExtractor):
else:
content_id = self._search_regex(r'''contentId\s*:\s*['"]([0-9a-zA-Z]+?)['\"]''', webpage, 'content_id')
create_date = self._search_regex(r'''createDate\s*:\s*['"]([0-9]{14})['"]''', webpage, 'create_date', fatal=False) or \
create_date_str = self._search_regex(r'''createDate\s*:\s*['"]([0-9]{14})['"]''', webpage, 'create_date', fatal=False) or \
self._search_regex(r'''["']https?://songle\.jp/songs/piapro\.jp.*([0-9]{14})['"]''', webpage, 'create_date')
create_date = datetime.strptime(create_date_str, '%Y%m%d%H%M%S')
create_date_unix = (create_date - datetime(1970,1,1)).total_seconds()
uploader = get_element_by_class("cd_user-name", webpage)
try:
@ -55,9 +57,9 @@ class PiaproIE(InfoExtractor):
'description': get_element_by_class("cd_dtl_cap", webpage),
'id': content_id,
'thumbnail': self._search_regex(r'(https?://c1\.piapro\.jp/timg/.+?_1440\.jpg)', webpage, 'thumbnail', fatal=False),
'timestamp': int(datetime.strptime(create_date, '%Y%m%d%H%M%S').strftime("%s")),
'timestamp': create_date_unix,
'title': get_element_by_class("works-title", webpage) or self._html_search_regex(r'<title>[^<]*「(.*?)」<', webpage, 'title', fatal=False),
'uploader': uploader_without_honorific or uploader,
# 'uploader_url': self._search_regex(r'<a\s+.*?href="(https?://piapro\.jp/.+?)"', cls_userbar_name, 'uploader_url', fatal=False), # FIXME
'url': 'http://cdn.piapro.jp/mp3_a/{}/{}_{}_audition.mp3'.format(content_id[:2], content_id, create_date)
'url': 'http://cdn.piapro.jp/mp3_a/{}/{}_{}_audition.mp3'.format(content_id[:2], content_id, create_date_str)
}