mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-11-18 11:30:11 +09:00
[utils] Disambiguate 4-digit year and time-zone suffix
Restore check omitted from extract_timezone(); adjust DATE_FORMATS_DAY/MONTH_FIRST; add tests.
This commit is contained in:
parent
d87e2ad040
commit
7990d1e630
@ -405,6 +405,12 @@ class TestUtil(unittest.TestCase):
|
||||
self.assertEqual(unified_timestamp('December 31 1969 20:00:01 EDT'), 1)
|
||||
self.assertEqual(unified_timestamp('Wednesday 31 December 1969 18:01:26 MDT'), 86)
|
||||
self.assertEqual(unified_timestamp('12/31/1969 20:01:18 EDT', False), 78)
|
||||
self.assertEqual(unified_timestamp('11:31 17-Jun-2021'), 1623929460)
|
||||
self.assertEqual(unified_timestamp('11:31 17-Jun-2021-0000'), 1623929460)
|
||||
from youtube_dl.utils import DATE_FORMATS_DAY_FIRST
|
||||
DATE_FORMATS_DAY_FIRST.append('%H:%M %d-%m-%Y')
|
||||
self.assertEqual(unified_timestamp('17:30 27-02-2016'), 1456594200)
|
||||
self.assertEqual(unified_timestamp('17:30 27-02-2016-0000'), 1456594200)
|
||||
|
||||
def test_determine_ext(self):
|
||||
self.assertEqual(determine_ext('http://example.com/foo/bar.mp4/?download'), 'mp4')
|
||||
|
@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
from __future__ import unicode_literals
|
||||
@ -1734,8 +1733,6 @@ ACCENT_CHARS = dict(zip('ÂÃÄÀÁÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖŐØŒÙ
|
||||
'aaaaaa', ['ae'], 'ceeeeiiiionooooooo', ['oe'], 'uuuuuy', ['th'], 'y')))
|
||||
|
||||
DATE_FORMATS = (
|
||||
'%d %B %Y',
|
||||
'%d %b %Y',
|
||||
'%B %d %Y',
|
||||
'%B %dst %Y',
|
||||
'%B %dnd %Y',
|
||||
@ -1787,6 +1784,11 @@ DATE_FORMATS_DAY_FIRST.extend([
|
||||
'%d/%m/%y',
|
||||
'%d/%m/%Y %H:%M:%S',
|
||||
'%d-%m-%Y %H:%M',
|
||||
'%d %B %Y',
|
||||
'%d %b %Y',
|
||||
'%d-%b-%Y',
|
||||
'%H:%M %d-%b-%Y',
|
||||
'%H:%M:%S %d-%b-%Y',
|
||||
])
|
||||
|
||||
DATE_FORMATS_MONTH_FIRST = list(DATE_FORMATS)
|
||||
@ -1796,6 +1798,11 @@ DATE_FORMATS_MONTH_FIRST.extend([
|
||||
'%m/%d/%Y',
|
||||
'%m/%d/%y',
|
||||
'%m/%d/%Y %H:%M:%S',
|
||||
'%B %d %Y',
|
||||
'%b %d %Y',
|
||||
'%b-%d-%Y',
|
||||
'%H:%M %b-%d-%Y',
|
||||
'%H:%M:%S %b-%d-%Y',
|
||||
])
|
||||
|
||||
PACKED_CODES_RE = r"}\('(.+)',(\d+),(\d+),'([^']+)'\.split\('\|'\)"
|
||||
|
Loading…
Reference in New Issue
Block a user