mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 16:42:57 +01:00
Reworked 'upload_date' code for output sequence in YoutubeIE.
Reverted to previous version of 'upload_date' and fixed a mistake that prevented the code from working properly.
This commit is contained in:
parent
f8dc441430
commit
a1f03c7b06
35
youtube-dl
35
youtube-dl
@ -5,6 +5,7 @@
|
|||||||
# Author: Benjamin Johnson
|
# Author: Benjamin Johnson
|
||||||
# License: Public domain code
|
# License: Public domain code
|
||||||
import cookielib
|
import cookielib
|
||||||
|
import datetime
|
||||||
import htmlentitydefs
|
import htmlentitydefs
|
||||||
import httplib
|
import httplib
|
||||||
import locale
|
import locale
|
||||||
@ -36,21 +37,6 @@ std_headers = {
|
|||||||
|
|
||||||
simple_title_chars = string.ascii_letters.decode('ascii') + string.digits.decode('ascii')
|
simple_title_chars = string.ascii_letters.decode('ascii') + string.digits.decode('ascii')
|
||||||
|
|
||||||
month_name_to_number = {
|
|
||||||
'January': '01',
|
|
||||||
'February': '02',
|
|
||||||
'March': '03',
|
|
||||||
'April': '04',
|
|
||||||
'May': '05',
|
|
||||||
'June': '06',
|
|
||||||
'July': '07',
|
|
||||||
'August': '08',
|
|
||||||
'September': '09',
|
|
||||||
'October': '10',
|
|
||||||
'November': '11',
|
|
||||||
'December': '12',
|
|
||||||
}
|
|
||||||
|
|
||||||
def preferredencoding():
|
def preferredencoding():
|
||||||
"""Get preferred encoding.
|
"""Get preferred encoding.
|
||||||
|
|
||||||
@ -913,18 +899,13 @@ class YoutubeIE(InfoExtractor):
|
|||||||
upload_date = u'NA'
|
upload_date = u'NA'
|
||||||
mobj = re.search(r'id="eow-date".*?>(.*?)</span>', video_webpage, re.DOTALL)
|
mobj = re.search(r'id="eow-date".*?>(.*?)</span>', video_webpage, re.DOTALL)
|
||||||
if mobj is not None:
|
if mobj is not None:
|
||||||
try:
|
upload_date = ' '.join(re.sub(r'[/,-]', r' ', mobj.group(1)).split())
|
||||||
if ',' in mobj.group(1):
|
format_expressions = ['%d %B %Y', '%B %d %Y']
|
||||||
# Month Day, Year
|
for expression in format_expressions:
|
||||||
m, d, y = mobj.group(1).replace(',', '').split()
|
try:
|
||||||
else:
|
upload_date = datetime.datetime.strptime(upload_date, expression).strftime('%Y%m%d')
|
||||||
# Day Month Year, we'll suppose
|
except:
|
||||||
d, m, y = mobj.group(1).split()
|
pass
|
||||||
m = month_name_to_number[m]
|
|
||||||
d = '%02d' % (long(d))
|
|
||||||
upload_date = '%s%s%s' % (y, m, d)
|
|
||||||
except:
|
|
||||||
upload_date = u'NA'
|
|
||||||
|
|
||||||
# description
|
# description
|
||||||
video_description = 'No description available.'
|
video_description = 'No description available.'
|
||||||
|
Loading…
Reference in New Issue
Block a user