X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Futils.py;h=3574fc615c6eb54228c9b07c47ff0499b72333b7;hb=64e7ad6045990f01b250b622b9934035f75da624;hp=3943cc9c578fc7acd9dfd21cea7e2ad25d4b1410;hpb=bcf89ce62cb4f6ab8802ab6aef01c3afaefc0075;p=youtube-dl diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 3943cc9c5..3574fc615 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -6,6 +6,7 @@ import ctypes import datetime import email.utils import errno +import getpass import gzip import itertools import io @@ -762,6 +763,10 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler): def unified_strdate(date_str): """Return a string with the date in the format YYYYMMDD""" + + if date_str is None: + return None + upload_date = None #Replace commas date_str = date_str.replace(',', ' ') @@ -778,6 +783,7 @@ def unified_strdate(date_str): '%Y/%m/%d %H:%M:%S', '%Y-%m-%d %H:%M:%S', '%d.%m.%Y %H:%M', + '%d.%m.%Y %H.%M', '%Y-%m-%dT%H:%M:%SZ', '%Y-%m-%dT%H:%M:%S.%fZ', '%Y-%m-%dT%H:%M:%S.%f0Z', @@ -1278,3 +1284,21 @@ def parse_xml(s): parser = xml.etree.ElementTree.XMLParser(target=TreeBuilder()) kwargs = {'parser': parser} if sys.version_info >= (2, 7) else {} return xml.etree.ElementTree.XML(s.encode('utf-8'), **kwargs) + + +if sys.version_info < (3, 0) and sys.platform == 'win32': + def compat_getpass(prompt, *args, **kwargs): + if isinstance(prompt, compat_str): + prompt = prompt.encode(preferredencoding()) + return getpass.getpass(prompt, *args, **kwargs) +else: + compat_getpass = getpass.getpass + + +US_RATINGS = { + 'G': 0, + 'PG': 10, + 'PG-13': 13, + 'R': 16, + 'NC': 18, +}