This commit is contained in:
pukkandan 2022-12-21 20:34:30 +00:00 committed by GitHub
commit f99ef14e7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
612 changed files with 1541 additions and 3893 deletions

View file

@ -66,16 +66,10 @@ jobs:
env:
YTDL_TEST_SET: ${{ matrix.ytdl-test-set }}
run: ./devscripts/run_tests.${{ matrix.run-tests-ext }}
flake8:
pre_commit:
name: Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install flake8
run: pip install flake8
- name: Run flake8
run: flake8 .
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0

13
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pycqa/isort
rev: v5.11.3
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.1
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8

View file

@ -2,8 +2,8 @@
from __future__ import unicode_literals
import os
from os.path import dirname as dirn
import sys
from os.path import dirname as dirn
sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))
import youtube_dl

View file

@ -3,18 +3,18 @@
import argparse
import ctypes
import functools
import os.path
import shutil
import subprocess
import sys
import tempfile
import threading
import traceback
import os.path
sys.path.insert(0, os.path.dirname(os.path.dirname((os.path.abspath(__file__)))))
from youtube_dl.compat import (
compat_input,
compat_http_server,
compat_input,
compat_str,
compat_urlparse,
)
@ -336,7 +336,7 @@ class YoutubeDLBuilder(object):
try:
proc = subprocess.Popen([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'], stdin=subprocess.PIPE, cwd=self.buildPath)
proc.wait()
#subprocess.check_output([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'],
# subprocess.check_output([os.path.join(self.pythonPath, 'python.exe'), 'setup.py', 'py2exe'],
# cwd=self.buildPath)
except subprocess.CalledProcessError as e:
raise BuildError(e.output)
@ -429,5 +429,6 @@ class BuildHTTPRequestHandler(compat_http_server.BaseHTTPRequestHandler):
else:
self.send_response(500, 'Malformed URL')
if __name__ == '__main__':
main()

View file

@ -12,11 +12,11 @@ pass the list filename as the only argument
# Allow direct execution
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import gettestcases
from youtube_dl.utils import compat_urllib_parse_urlparse
from youtube_dl.utils import compat_urllib_request
from youtube_dl.utils import compat_urllib_parse_urlparse, compat_urllib_request
if len(sys.argv) > 1:
METHOD = 'LIST'

View file

@ -18,10 +18,7 @@ from youtube_dl.compat import (
compat_print,
compat_urllib_request,
)
from youtube_dl.utils import (
make_HTTPS_handler,
sanitized_Request,
)
from youtube_dl.utils import make_HTTPS_handler, sanitized_Request
class GitHubReleaser(object):

View file

@ -3,8 +3,8 @@ from __future__ import unicode_literals
import optparse
import os
from os.path import dirname as dirn
import sys
from os.path import dirname as dirn
sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))
import youtube_dl

View file

@ -1,14 +1,14 @@
from __future__ import unicode_literals
import codecs
import subprocess
import os
import subprocess
import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.utils import intlist_to_bytes
from youtube_dl.aes import aes_encrypt, key_expansion
from youtube_dl.utils import intlist_to_bytes
secret_msg = b'Secret message goes here'

View file

@ -1,11 +1,10 @@
#!/usr/bin/env python3
from __future__ import unicode_literals
import json
import sys
import hashlib
import json
import os.path
import sys
if len(sys.argv) <= 1:
print('Specify the version number as parameter')

View file

@ -1,10 +1,11 @@
#!/usr/bin/env python3
from __future__ import unicode_literals, with_statement
import rsa
import json
from binascii import hexlify
import rsa
try:
input = raw_input
except NameError:

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
# coding: utf-8
from __future__ import with_statement, unicode_literals
from __future__ import unicode_literals, with_statement
import datetime
import glob

View file

@ -6,7 +6,6 @@ import io
import json
import textwrap
atom_template = textwrap.dedent("""\
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
@ -40,8 +39,7 @@ now_iso = now.isoformat() + 'Z'
atom_template = atom_template.replace('@TIMESTAMP@', now_iso)
versions_info = json.load(open('update/versions.json'))
versions = list(versions_info['versions'].keys())
versions.sort()
versions = sorted(versions_info['versions'].keys())
entries = []
for v in versions:

View file

@ -1,8 +1,8 @@
#!/usr/bin/env python3
from __future__ import unicode_literals
import sys
import os
import sys
import textwrap
# We must be able to import youtube_dl

View file

@ -25,5 +25,6 @@ def main():
with io.open(outfile, 'w', encoding='utf-8') as outf:
outf.write(out)
if __name__ == '__main__':
main()

View file

@ -1,10 +1,10 @@
from __future__ import unicode_literals, print_function
from __future__ import print_function, unicode_literals
from inspect import getsource
import io
import os
from os.path import dirname as dirn
import sys
from inspect import getsource
from os.path import dirname as dirn
print('WARNING: Lazy loading extractors is an experimental feature that may not always work', file=sys.stderr)

View file

@ -1,8 +1,8 @@
from __future__ import unicode_literals
import io
import sys
import re
import sys
README_FILE = 'README.md'
helptext = sys.stdin.read()

View file

@ -6,7 +6,6 @@ import optparse
import os
import sys
# Import youtube_dl
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')
sys.path.insert(0, ROOT_DIR)

View file

@ -9,10 +9,7 @@ import sys
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.compat import (
compat_print,
compat_urllib_request,
)
from youtube_dl.compat import compat_print, compat_urllib_request
from youtube_dl.utils import format_bytes

View file

@ -2,8 +2,8 @@
from __future__ import unicode_literals
import os
from os.path import dirname as dirn
import sys
from os.path import dirname as dirn
sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))
import youtube_dl

View file

@ -12,8 +12,9 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import sys
# Allows to import youtube_dl
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@ -45,6 +46,7 @@ copyright = u'2014, Ricardo Garcia Gonzalez'
#
# The short X.Y version.
from youtube_dl.version import __version__
version = __version__
# The full version, including alpha/beta/rc tags.
release = version

View file

@ -2,5 +2,18 @@
universal = True
[flake8]
exclude = youtube_dl/extractor/__init__.py,devscripts/buildserver.py,devscripts/lazy_load_template.py,devscripts/make_issue_template.py,setup.py,build,.git,venv
exclude = build,venv,.tox,.git,.pytest_cache,devscripts/buildserver.py
ignore = E402,E501,E731,E741,W503
max_line_length = 80
per_file_ignores =
devscripts/lazy_load_template.py: F401
[isort]
py_version = 27
multi_line_output = VERTICAL_HANGING_INDENT
line_length = 80
reverse_relative = true
ensure_newline_before_comments = true
include_trailing_comma = true
known_first_party =
test

View file

@ -4,21 +4,21 @@
from __future__ import print_function
import os.path
import warnings
import sys
import warnings
try:
from setuptools import setup, Command
from setuptools import Command, setup
setuptools_available = True
except ImportError:
from distutils.core import setup, Command
from distutils.core import Command, setup
setuptools_available = False
from distutils.spawn import spawn
try:
# This will create an exe that needs Microsoft Visual C++ 2008
# Redistributable Package
import py2exe
import py2exe # noqa: F401
except ImportError:
if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe':
print('Cannot import py2exe', file=sys.stderr)
@ -42,11 +42,11 @@ LONG_DESCRIPTION = 'Command-line program to download videos from YouTube.com and
py2exe_console = [{
'script': './youtube_dl/__main__.py',
'dest_base': 'youtube-dl',
'version': __version__,
'version': __version__, # noqa: F821
'description': DESCRIPTION,
'comments': LONG_DESCRIPTION,
'product_name': 'youtube-dl',
'product_version': __version__,
'product_version': __version__, # noqa: F821
}]
py2exe_params = {
@ -83,6 +83,7 @@ else:
else:
params['scripts'] = ['bin/youtube-dl']
class build_lazy_extractors(Command):
description = 'Build the extractor lazy loading module'
user_options = []
@ -99,9 +100,10 @@ class build_lazy_extractors(Command):
dry_run=self.dry_run,
)
setup(
name='youtube_dl',
version=__version__,
version=__version__, # noqa: F821
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
url='https://github.com/ytdl-org/youtube-dl',

View file

@ -1,25 +1,19 @@
from __future__ import unicode_literals
import errno
import io
import hashlib
import io
import json
import os.path
import re
import types
import ssl
import sys
import types
import youtube_dl.extractor
from youtube_dl import YoutubeDL
from youtube_dl.compat import (
compat_os_name,
compat_str,
)
from youtube_dl.utils import (
preferredencoding,
write_string,
)
from youtube_dl.compat import compat_os_name, compat_str
from youtube_dl.utils import preferredencoding, write_string
def get_params(override=None):

View file

@ -7,15 +7,21 @@ import io
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import threading
from test.helper import FakeYDL, expect_dict, expect_value, http_server_port
from youtube_dl.compat import compat_etree_fromstring, compat_http_server
from youtube_dl.extractor.common import InfoExtractor
from youtube_dl.extractor import YoutubeIE, get_info_extractor
from youtube_dl.utils import encode_data_uri, strip_jsonp, ExtractorError, RegexNotFoundError
import threading
from youtube_dl.extractor.common import InfoExtractor
from youtube_dl.utils import (
ExtractorError,
RegexNotFoundError,
encode_data_uri,
strip_jsonp,
)
TEAPOT_RESPONSE_STATUS = 418
TEAPOT_RESPONSE_BODY = "<h1>418 I'm a teapot</h1>"

View file

@ -7,6 +7,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import copy

View file

@ -8,6 +8,7 @@ import re
import sys
import tempfile
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.utils import YoutubeDLCookieJar

View file

@ -6,12 +6,21 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.aes import aes_decrypt, aes_encrypt, aes_cbc_decrypt, aes_cbc_encrypt, aes_decrypt_text, aes_ecb_encrypt
from youtube_dl.utils import bytes_to_intlist, intlist_to_bytes
import base64
from youtube_dl.aes import (
aes_cbc_decrypt,
aes_cbc_encrypt,
aes_decrypt,
aes_decrypt_text,
aes_ecb_encrypt,
aes_encrypt,
)
from youtube_dl.utils import bytes_to_intlist, intlist_to_bytes
# the encrypted data can be generate with 'devscripts/generate_aes_testdata.py'

View file

@ -5,11 +5,10 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import try_rm
from youtube_dl import YoutubeDL

View file

@ -2,21 +2,18 @@
from __future__ import unicode_literals
import collections
# Allow direct execution
import os
import sys
import unittest
import collections
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import gettestcases
from youtube_dl.extractor import (
FacebookIE,
gen_extractors,
YoutubeIE,
)
from youtube_dl.extractor import FacebookIE, YoutubeIE, gen_extractors
class TestAllURLsMatching(unittest.TestCase):

View file

@ -7,6 +7,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import shutil

View file

@ -7,16 +7,17 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.compat import (
compat_casefold,
compat_getenv,
compat_setenv,
compat_etree_Element,
compat_etree_fromstring,
compat_expanduser,
compat_getenv,
compat_setenv,
compat_shlex_split,
compat_str,
compat_struct_unpack,

View file

@ -6,38 +6,37 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import (
assertGreaterEqual,
expect_warnings,
get_params,
gettestcases,
expect_info_dict,
try_rm,
report_warning,
)
import hashlib
import io
import json
import socket
import youtube_dl.YoutubeDL
from test.helper import (
assertGreaterEqual,
expect_info_dict,
expect_warnings,
get_params,
gettestcases,
report_warning,
try_rm,
)
from youtube_dl.compat import (
compat_http_client,
compat_urllib_error,
compat_HTTPError,
compat_urllib_error,
)
from youtube_dl.extractor import get_info_extractor
from youtube_dl.utils import (
DownloadError,
ExtractorError,
UnavailableVideoError,
error_to_compat_str,
format_bytes,
UnavailableVideoError,
)
from youtube_dl.extractor import get_info_extractor
RETRIES = 3

View file

@ -7,14 +7,16 @@ import os
import re
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import threading
from test.helper import http_server_port, try_rm
from youtube_dl import YoutubeDL
from youtube_dl.compat import compat_http_server
from youtube_dl.downloader.http import HttpFD
from youtube_dl.utils import encodeFilename
import threading
TEST_DIR = os.path.dirname(os.path.abspath(__file__))

View file

@ -3,11 +3,11 @@
from __future__ import unicode_literals
import unittest
import sys
import os
import subprocess
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.utils import encodeArgument

View file

@ -6,13 +6,15 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import ssl
import threading
from test.helper import http_server_port
from youtube_dl import YoutubeDL
from youtube_dl.compat import compat_http_server, compat_urllib_request
import ssl
import threading
TEST_DIR = os.path.dirname(os.path.abspath(__file__))

View file

@ -6,6 +6,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL

View file

@ -6,13 +6,13 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import math
import re
from youtube_dl.compat import compat_re_Pattern
from youtube_dl.jsinterp import JS_Undefined, JSInterpreter

View file

@ -4,12 +4,11 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.extractor import (
gen_extractors,
)
from youtube_dl.extractor import gen_extractors
class TestNetRc(unittest.TestCase):

View file

@ -6,6 +6,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.options import _hide_login_info

View file

@ -6,6 +6,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from youtube_dl.postprocessor import MetadataFromTitlePP

View file

@ -6,19 +6,14 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import random
import subprocess
from test.helper import (
FakeYDL,
get_params,
)
from youtube_dl.compat import (
compat_str,
compat_urllib_request,
)
from test.helper import FakeYDL, get_params
from youtube_dl.compat import compat_str, compat_urllib_request
class TestMultipleSocks(unittest.TestCase):

View file

@ -5,28 +5,27 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL, md5
from youtube_dl.extractor import (
YoutubeIE,
DailymotionIE,
NPOIE,
NRKTVIE,
TEDIE,
CeskaTelevizeIE,
ComedyCentralIE,
DailymotionIE,
DemocracynowIE,
LyndaIE,
RaiPlayIE,
RTVEALaCartaIE,
ThePlatformFeedIE,
ThePlatformIE,
VikiIE,
VimeoIE,
WallaIE,
CeskaTelevizeIE,
LyndaIE,
NPOIE,
ComedyCentralIE,
NRKTVIE,
RaiPlayIE,
VikiIE,
ThePlatformIE,
ThePlatformFeedIE,
RTVEALaCartaIE,
DemocracynowIE,
YoutubeIE,
)

View file

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@ -16,7 +17,6 @@ import subprocess
from youtube_dl.swfinterp import SWFInterpreter
TEST_DIR = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'swftests')

View file

@ -4,6 +4,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import io

View file

@ -6,10 +6,12 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import json
from youtube_dl.update import rsa_verify

View file

@ -7,6 +7,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@ -17,66 +18,86 @@ import json
import re
import xml.etree.ElementTree
from youtube_dl.compat import (
compat_chr,
compat_etree_fromstring,
compat_getenv,
compat_os_name,
compat_parse_qs,
compat_setenv,
compat_str,
compat_urlparse,
)
from youtube_dl.utils import (
DateRange,
ExtractorError,
InAdvancePagedList,
LazyList,
OnDemandPagedList,
age_restricted,
args_to_str,
encode_base_n,
base_url,
caesar,
clean_html,
clean_podcast_url,
cli_bool_option,
cli_option,
cli_valueless_option,
date_from_str,
DateRange,
detect_exe_version,
determine_ext,
dfxp2srt,
dict_get,
encode_base_n,
encode_compat_str,
encodeFilename,
escape_rfc3986,
escape_url,
expand_path,
extract_attributes,
ExtractorError,
find_xpath_attr,
fix_xml_ampersands,
float_or_none,
get_element_by_class,
get_element_by_attribute,
get_elements_by_class,
get_element_by_class,
get_elements_by_attribute,
get_elements_by_class,
get_first,
InAdvancePagedList,
int_or_none,
intlist_to_bytes,
is_html,
join_nonempty,
js_to_json,
LazyList,
limit_length,
lowercase_escape,
match_str,
merge_dicts,
mimetype2ext,
month_by_name,
multipart_encode,
ohdave_rsa_encrypt,
OnDemandPagedList,
orderedSet,
parse_age_limit,
parse_bitrate,
parse_codecs,
parse_count,
parse_dfxp_time_expr,
parse_duration,
parse_filesize,
parse_count,
parse_iso8601,
parse_resolution,
parse_bitrate,
pkcs1pad,
prepend_extension,
read_batch_urls,
remove_end,
remove_quotes,
remove_start,
render_table,
replace_extension,
rot47,
sanitize_filename,
sanitize_path,
sanitize_url,
expand_path,
prepend_extension,
replace_extension,
remove_start,
remove_end,
remove_quotes,
rot47,
shell_quote,
smuggle_url,
str_to_int,
@ -90,39 +111,19 @@ from youtube_dl.utils import (
unified_strdate,
unified_timestamp,
unsmuggle_url,
update_url_query,
uppercase_escape,
lowercase_escape,
url_basename,
url_or_none,
base_url,
urljoin,
urlencode_postdata,
urljoin,
urshift,
update_url_query,
variadic,
version_tuple,
xpath_with_ns,
xpath_attr,
xpath_element,
xpath_text,
xpath_attr,
render_table,
match_str,
parse_dfxp_time_expr,
dfxp2srt,
cli_option,
cli_valueless_option,
cli_bool_option,
parse_codecs,
)
from youtube_dl.compat import (
compat_chr,
compat_etree_fromstring,
compat_getenv,
compat_os_name,
compat_setenv,
compat_str,
compat_urlparse,
compat_parse_qs,
xpath_with_ns,
)

View file

@ -3,11 +3,11 @@
from __future__ import unicode_literals
import unittest
import sys
import os
import subprocess
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

View file

@ -6,17 +6,15 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import get_params, try_rm
import io
import xml.etree.ElementTree
import youtube_dl.YoutubeDL
import youtube_dl.extractor
import youtube_dl.YoutubeDL
from test.helper import get_params, try_rm
class YoutubeDL(youtube_dl.YoutubeDL):

View file

@ -6,15 +6,11 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import FakeYDL
from youtube_dl.extractor import (
YoutubeIE,
YoutubePlaylistIE,
YoutubeTabIE,
)
from youtube_dl.extractor import YoutubeIE, YoutubePlaylistIE, YoutubeTabIE
class TestYoutubeLists(unittest.TestCase):

View file

@ -5,6 +5,7 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

View file

@ -6,15 +6,15 @@ from __future__ import unicode_literals
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import io
import re
import string
from youtube_dl.compat import compat_str, compat_urlretrieve
from test.helper import FakeYDL
from youtube_dl.compat import compat_str, compat_urlretrieve
from youtube_dl.extractor import YoutubeIE
from youtube_dl.jsinterp import JSInterpreter

View file

@ -16,18 +16,18 @@ import locale
import operator
import os
import platform
import random
import re
import shutil
import subprocess
import socket
import subprocess
import sys
import time
import tokenize
import traceback
import random
from string import ascii_letters
from .cache import Cache
from .compat import (
compat_basestring,
compat_cookiejar,
@ -42,64 +42,10 @@ from .compat import (
compat_urllib_request,
compat_urllib_request_DataHandler,
)
from .utils import (
age_restricted,
args_to_str,
ContentTooShortError,
date_from_str,
DateRange,
DEFAULT_OUTTMPL,
determine_ext,
determine_protocol,
DownloadError,
encode_compat_str,
encodeFilename,
error_to_compat_str,
expand_path,
ExtractorError,
format_bytes,
formatSeconds,
GeoRestrictedError,
int_or_none,
ISO3166Utils,
locked_file,
make_HTTPS_handler,
MaxDownloadsReached,
orderedSet,
PagedList,
parse_filesize,
PerRequestProxyHandler,
platform_name,
PostProcessingError,
preferredencoding,
prepend_extension,
process_communicate_or_kill,
register_socks_protocols,
render_table,
replace_extension,
SameFileError,
sanitize_filename,
sanitize_path,
sanitize_url,
sanitized_Request,
std_headers,
str_or_none,
subtitles_filename,
UnavailableVideoError,
url_basename,
version_tuple,
write_json_file,
write_string,
YoutubeDLCookieJar,
YoutubeDLCookieProcessor,
YoutubeDLHandler,
YoutubeDLRedirectHandler,
)
from .cache import Cache
from .extractor import get_info_extractor, gen_extractor_classes, _LAZY_LOADER
from .extractor.openload import PhantomJSwrapper
from .downloader import get_suitable_downloader
from .downloader.rtmp import rtmpdump_version
from .extractor import _LAZY_LOADER, gen_extractor_classes, get_info_extractor
from .extractor.openload import PhantomJSwrapper
from .postprocessor import (
FFmpegFixupM3u8PP,
FFmpegFixupM4aPP,
@ -108,6 +54,59 @@ from .postprocessor import (
FFmpegPostProcessor,
get_postprocessor,
)
from .utils import (
DEFAULT_OUTTMPL,
ContentTooShortError,
DateRange,
DownloadError,
ExtractorError,
GeoRestrictedError,
ISO3166Utils,
MaxDownloadsReached,
PagedList,
PerRequestProxyHandler,
PostProcessingError,
SameFileError,
UnavailableVideoError,
YoutubeDLCookieJar,
YoutubeDLCookieProcessor,
YoutubeDLHandler,
YoutubeDLRedirectHandler,
age_restricted,
args_to_str,
date_from_str,
determine_ext,
determine_protocol,
encode_compat_str,
encodeFilename,
error_to_compat_str,
expand_path,
format_bytes,
formatSeconds,
int_or_none,
locked_file,
make_HTTPS_handler,
orderedSet,
parse_filesize,
platform_name,
preferredencoding,
prepend_extension,
process_communicate_or_kill,
register_socks_protocols,
render_table,
replace_extension,
sanitize_filename,
sanitize_path,
sanitize_url,
sanitized_Request,
std_headers,
str_or_none,
subtitles_filename,
url_basename,
version_tuple,
write_json_file,
write_string,
)
from .version import __version__
if compat_os_name == 'nt':

View file

@ -11,37 +11,32 @@ import os
import random
import sys
from .options import (
parseOpts,
)
from .compat import (
compat_getpass,
compat_shlex_split,
workaround_optparse_bug9161,
)
from .downloader import FileDownloader
from .extractor import gen_extractors, list_extractors
from .extractor.adobepass import MSO_INFO
from .options import parseOpts
from .update import update_self
from .utils import (
DateRange,
decodeOption,
DEFAULT_OUTTMPL,
DateRange,
DownloadError,
MaxDownloadsReached,
SameFileError,
decodeOption,
expand_path,
match_filter_func,
MaxDownloadsReached,
preferredencoding,
read_batch_urls,
SameFileError,
render_table,
setproctitle,
std_headers,
write_string,
render_table,
)
from .update import update_self
from .downloader import (
FileDownloader,
)
from .extractor import gen_extractors, list_extractors
from .extractor.adobepass import MSO_INFO
from .YoutubeDL import YoutubeDL

View file

@ -1,11 +1,12 @@
#!/usr/bin/env python
from __future__ import unicode_literals
import sys
# Execute with
# $ python youtube_dl/__main__.py (2.6+)
# $ python -m youtube_dl (2.7+)
import sys
if __package__ is None and not hasattr(sys, 'frozen'):
# direct call of __main__.py

View file

@ -1,10 +1,7 @@
# coding: utf-8
from __future__ import unicode_literals
from .compat import (
compat_str,
compat_chr,
)
from .compat import compat_chr, compat_str
# Below is included the text of icu/CaseFolding.txt retrieved from
# https://github.com/unicode-org/icu/blob/main/icu4c/source/data/unidata/CaseFolding.txt

View file

@ -2387,9 +2387,10 @@ except ImportError:
import BaseHTTPServer as compat_http_server
try:
from urllib.parse import unquote_to_bytes as compat_urllib_parse_unquote_to_bytes
from urllib.parse import unquote as compat_urllib_parse_unquote
from urllib.parse import unquote_plus as compat_urllib_parse_unquote_plus
from urllib.parse import \
unquote_to_bytes as compat_urllib_parse_unquote_to_bytes
except ImportError: # Python 2
_asciire = (compat_urllib_parse._asciire if hasattr(compat_urllib_parse, '_asciire')
else re.compile(r'([\x00-\x7f]+)'))
@ -2684,7 +2685,7 @@ except (AssertionError, UnicodeEncodeError):
def compat_ord(c):
if type(c) is int:
if isinstance(c, int):
return c
else:
return ord(c)
@ -3001,6 +3002,7 @@ except ImportError:
# new class in collections
try:
from collections import ChainMap as compat_collections_chain_map
# Py3.3's ChainMap is deficient
if sys.version_info < (3, 4):
raise ImportError

View file

@ -1,8 +1,6 @@
from __future__ import unicode_literals
from ..utils import (
determine_protocol,
)
from ..utils import determine_protocol
def get_suitable_downloader(info_dict, params={}):
@ -14,17 +12,14 @@ def get_suitable_downloader(info_dict, params={}):
# Some of these require get_suitable_downloader
from .common import FileDownloader
from .dash import DashSegmentsFD
from .external import FFmpegFD, get_external_downloader
from .f4m import F4mFD
from .hls import HlsFD
from .http import HttpFD
from .rtmp import RtmpFD
from .rtsp import RtspFD
from .ism import IsmFD
from .niconico import NiconicoDmcFD
from .external import (
get_external_downloader,
FFmpegFD,
)
from .rtmp import RtmpFD
from .rtsp import RtspFD
PROTOCOL_MAP = {
'rtmp': RtmpFD,

View file

@ -1,10 +1,10 @@
from __future__ import division, unicode_literals
import os
import random
import re
import sys
import time
import random
from ..compat import compat_os_name
from ..utils import (

View file

@ -2,10 +2,7 @@ from __future__ import unicode_literals
from .fragment import FragmentFD
from ..compat import compat_urllib_error
from ..utils import (
DownloadError,
urljoin,
)
from ..utils import DownloadError, urljoin
class DashSegmentsFD(FragmentFD):

View file

@ -7,20 +7,17 @@ import sys
import time
from .common import FileDownloader
from ..compat import (
compat_setenv,
compat_str,
)
from ..postprocessor.ffmpeg import FFmpegPostProcessor, EXT_TO_OUT_FORMATS
from ..compat import compat_setenv, compat_str
from ..postprocessor.ffmpeg import EXT_TO_OUT_FORMATS, FFmpegPostProcessor
from ..utils import (
cli_option,
cli_valueless_option,
check_executable,
cli_bool_option,
cli_configuration_args,
encodeFilename,
cli_option,
cli_valueless_option,
encodeArgument,
encodeFilename,
handle_youtubedl_headers,
check_executable,
is_outdated_version,
process_communicate_or_kill,
)

View file

@ -8,16 +8,13 @@ from .fragment import FragmentFD
from ..compat import (
compat_b64decode,
compat_etree_fromstring,
compat_urlparse,
compat_urllib_error,
compat_urllib_parse_urlparse,
compat_struct_pack,
compat_struct_unpack,
compat_urllib_error,
compat_urllib_parse_urlparse,
compat_urlparse,
)
from ..utils import (
fix_xml_ampersands,
xpath_text,
)
from ..utils import fix_xml_ampersands, xpath_text
class DataTruncatedError(Exception):

View file

@ -1,14 +1,14 @@
from __future__ import division, unicode_literals
import json
import os
import time
import json
from .common import FileDownloader
from .http import HttpFD
from ..utils import (
error_to_compat_str,
encodeFilename,
error_to_compat_str,
sanitize_open,
sanitized_Request,
)

View file

@ -1,25 +1,18 @@
from __future__ import unicode_literals
import re
import binascii
import re
try:
from Crypto.Cipher import AES
can_decrypt_frag = True
except ImportError:
can_decrypt_frag = False
from .fragment import FragmentFD
from .external import FFmpegFD
from ..compat import (
compat_urllib_error,
compat_urlparse,
compat_struct_pack,
)
from ..utils import (
parse_m3u8_attributes,
update_url_query,
)
from .fragment import FragmentFD
from ..compat import compat_struct_pack, compat_urllib_error, compat_urlparse
from ..utils import parse_m3u8_attributes, update_url_query
class HlsFD(FragmentFD):

View file

@ -2,25 +2,22 @@ from __future__ import unicode_literals
import errno
import os
import socket
import time
import random
import re
import socket
import time
from .common import FileDownloader
from ..compat import (
compat_str,
compat_urllib_error,
)
from ..compat import compat_str, compat_urllib_error
from ..utils import (
ContentTooShortError,
XAttrMetadataError,
XAttrUnavailableError,
encodeFilename,
int_or_none,
sanitize_open,
sanitized_Request,
write_xattr,
XAttrMetadataError,
XAttrUnavailableError,
)

View file

@ -1,15 +1,11 @@
from __future__ import unicode_literals
import time
import binascii
import io
import time
from .fragment import FragmentFD
from ..compat import (
compat_Struct,
compat_urllib_error,
)
from ..compat import compat_Struct, compat_urllib_error
u8 = compat_Struct('>B')
u88 = compat_Struct('>Bx')

View file

@ -9,8 +9,8 @@ from .common import FileDownloader
from ..compat import compat_str
from ..utils import (
check_executable,
encodeFilename,
encodeArgument,
encodeFilename,
get_exe_version,
)

View file

@ -4,10 +4,7 @@ import os
import subprocess
from .common import FileDownloader
from ..utils import (
check_executable,
encodeFilename,
)
from ..utils import check_executable, encodeFilename
class RtspFD(FileDownloader):

View file

@ -1,19 +1,19 @@
from __future__ import unicode_literals
try:
from .lazy_extractors import *
from .lazy_extractors import * # noqa: F403
from .lazy_extractors import _ALL_CLASSES
_LAZY_LOADER = True
except ImportError:
_LAZY_LOADER = False
from .extractors import *
from .extractors import * # noqa: F403
_ALL_CLASSES = [
klass
for name, klass in globals().items()
if name.endswith('IE') and name != 'GenericIE'
]
_ALL_CLASSES.append(GenericIE)
_ALL_CLASSES.append(GenericIE) # noqa: F405
def gen_extractor_classes():

View file

@ -9,8 +9,8 @@ from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
ExtractorError,
js_to_json,
int_or_none,
js_to_json,
parse_iso8601,
try_get,
unescapeHTML,

View file

@ -5,11 +5,7 @@ import re
from .amp import AMPIE
from .common import InfoExtractor
from ..utils import (
parse_duration,
parse_iso8601,
try_get,
)
from ..utils import parse_duration, parse_iso8601, try_get
class AbcNewsVideoIE(AMPIE):

View file

@ -5,11 +5,7 @@ import re
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
dict_get,
int_or_none,
try_get,
)
from ..utils import dict_get, int_or_none, try_get
class ABCOTVSIE(InfoExtractor):

View file

@ -4,12 +4,7 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
clean_html,
clean_podcast_url,
int_or_none,
parse_iso8601,
)
from ..utils import clean_html, clean_podcast_url, int_or_none, parse_iso8601
class ACastBaseIE(InfoExtractor):

View file

@ -9,15 +9,11 @@ import random
from .common import InfoExtractor
from ..aes import aes_cbc_decrypt
from ..compat import (
compat_HTTPError,
compat_b64decode,
compat_ord,
)
from ..compat import compat_b64decode, compat_HTTPError, compat_ord
from ..utils import (
ExtractorError,
bytes_to_intlist,
bytes_to_long,
ExtractorError,
float_or_none,
int_or_none,
intlist_to_bytes,

View file

@ -2,10 +2,7 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import (
compat_parse_qs,
compat_urlparse,
)
from ..compat import compat_parse_qs, compat_urlparse
class AdobeConnectIE(InfoExtractor):

View file

@ -6,19 +6,15 @@ import time
import xml.etree.ElementTree as etree
from .common import InfoExtractor
from ..compat import (
compat_kwargs,
compat_urlparse,
)
from ..compat import compat_kwargs, compat_urlparse
from ..utils import (
unescapeHTML,
urlencode_postdata,
unified_timestamp,
ExtractorError,
NO_DEFAULT,
ExtractorError,
unescapeHTML,
unified_timestamp,
urlencode_postdata,
)
MSO_INFO = {
'DTV': {
'name': 'DIRECTV',

View file

@ -6,10 +6,10 @@ import re
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
float_or_none,
int_or_none,
ISO639Utils,
OnDemandPagedList,
float_or_none,
int_or_none,
parse_duration,
str_or_none,
str_to_int,

View file

@ -6,8 +6,8 @@ import re
from .common import InfoExtractor
from ..compat import compat_xpath
from ..utils import (
determine_ext,
ExtractorError,
determine_ext,
int_or_none,
url_or_none,
urlencode_postdata,

View file

@ -4,11 +4,7 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
int_or_none,
parse_duration,
parse_iso8601,
)
from ..utils import int_or_none, parse_duration, parse_iso8601
class AirMozillaIE(InfoExtractor):

View file

@ -3,10 +3,7 @@ from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
float_or_none,
try_get,
)
from ..utils import float_or_none, try_get
class AliExpressLiveIE(InfoExtractor):

View file

@ -1,12 +1,7 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
parse_iso8601,
parse_duration,
parse_filesize,
int_or_none,
)
from ..utils import int_or_none, parse_duration, parse_filesize, parse_iso8601
class AlphaPornoIE(InfoExtractor):

View file

@ -2,13 +2,9 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from .youtube import YoutubeIE
from .vimeo import VimeoIE
from ..utils import (
int_or_none,
parse_iso8601,
update_url_query,
)
from .youtube import YoutubeIE
from ..utils import int_or_none, parse_iso8601, update_url_query
class AmaraIE(InfoExtractor):

View file

@ -4,12 +4,7 @@ from __future__ import unicode_literals
import re
from .theplatform import ThePlatformIE
from ..utils import (
int_or_none,
parse_age_limit,
try_get,
update_url_query,
)
from ..utils import int_or_none, parse_age_limit, try_get, update_url_query
class AMCNetworksIE(ThePlatformIE):

View file

@ -3,8 +3,8 @@ from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
determine_ext,
ExtractorError,
determine_ext,
int_or_none,
mimetype2ext,
parse_iso8601,

View file

@ -5,9 +5,9 @@ import re
from .common import InfoExtractor
from ..compat import compat_str
from ..utils import (
ExtractorError,
determine_ext,
extract_attributes,
ExtractorError,
url_or_none,
urlencode_postdata,
urljoin,

View file

@ -14,8 +14,8 @@ from ..compat import compat_str
from ..utils import (
bytes_to_intlist,
determine_ext,
intlist_to_bytes,
int_or_none,
intlist_to_bytes,
strip_jsonp,
unescapeHTML,
unsmuggle_url,

View file

@ -4,15 +4,8 @@ from __future__ import unicode_literals
import re
from .yahoo import YahooIE
from ..compat import (
compat_parse_qs,
compat_urllib_parse_urlparse,
)
from ..utils import (
ExtractorError,
int_or_none,
url_or_none,
)
from ..compat import compat_parse_qs, compat_urllib_parse_urlparse
from ..utils import ExtractorError, int_or_none, url_or_none
class AolIE(YahooIE):

View file

@ -4,11 +4,7 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
int_or_none,
url_or_none,
)
from ..utils import determine_ext, int_or_none, url_or_none
class APAIE(InfoExtractor):

View file

@ -2,10 +2,7 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
str_to_int,
ExtractorError
)
from ..utils import ExtractorError, str_to_int
class AppleConnectIE(InfoExtractor):

View file

@ -1,15 +1,11 @@
from __future__ import unicode_literals
import re
import json
import re
from .common import InfoExtractor
from ..compat import compat_urlparse
from ..utils import (
int_or_none,
parse_duration,
unified_strdate,
)
from ..utils import int_or_none, parse_duration, unified_strdate
class AppleTrailersIE(InfoExtractor):

View file

@ -4,12 +4,7 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
extract_attributes,
int_or_none,
parse_iso8601,
try_get,
)
from ..utils import extract_attributes, int_or_none, parse_iso8601, try_get
class ArcPublishingIE(InfoExtractor):

View file

@ -6,9 +6,10 @@ import re
from .common import InfoExtractor
from .generic import GenericIE
from ..compat import compat_etree_fromstring
from ..utils import (
determine_ext,
ExtractorError,
determine_ext,
int_or_none,
parse_duration,
qualities,
@ -20,7 +21,6 @@ from ..utils import (
url_or_none,
xpath_text,
)
from ..compat import compat_etree_fromstring
class ARDMediathekBaseIE(InfoExtractor):

View file

@ -2,16 +2,8 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..compat import (
compat_parse_qs,
compat_urllib_parse_urlparse,
)
from ..utils import (
float_or_none,
int_or_none,
parse_iso8601,
remove_start,
)
from ..compat import compat_parse_qs, compat_urllib_parse_urlparse
from ..utils import float_or_none, int_or_none, parse_iso8601, remove_start
class ArnesIE(InfoExtractor):

View file

@ -4,10 +4,7 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..compat import (
compat_str,
compat_urlparse,
)
from ..compat import compat_str, compat_urlparse
from ..utils import (
ExtractorError,
int_or_none,

View file

@ -7,9 +7,9 @@ import re
from .common import InfoExtractor
from .kaltura import KalturaIE
from ..utils import (
OnDemandPagedList,
extract_attributes,
int_or_none,
OnDemandPagedList,
parse_age_limit,
strip_or_none,
try_get,

View file

@ -5,11 +5,7 @@ import re
from .common import InfoExtractor
from ..compat import compat_HTTPError
from ..utils import (
ExtractorError,
int_or_none,
urlencode_postdata,
)
from ..utils import ExtractorError, int_or_none, urlencode_postdata
class AtresPlayerIE(InfoExtractor):

View file

@ -2,11 +2,7 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
determine_ext,
int_or_none,
unescapeHTML,
)
from ..utils import determine_ext, int_or_none, unescapeHTML
class ATVAtIE(InfoExtractor):

View file

@ -2,10 +2,7 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
int_or_none,
parse_iso8601,
)
from ..utils import int_or_none, parse_iso8601
class AudiMediaIE(InfoExtractor):

View file

@ -2,10 +2,7 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
clean_html,
float_or_none,
)
from ..utils import clean_html, float_or_none
class AudioBoomIE(InfoExtractor):

View file

@ -7,10 +7,7 @@ import time
from .common import InfoExtractor
from .soundcloud import SoundcloudIE
from ..compat import compat_str
from ..utils import (
ExtractorError,
url_basename,
)
from ..utils import ExtractorError, url_basename
class AudiomackIE(InfoExtractor):

View file

@ -1,14 +1,11 @@
# coding: utf-8
from __future__ import unicode_literals
import re
import base64
import re
from .common import InfoExtractor
from ..compat import (
compat_urllib_parse_urlencode,
compat_str,
)
from ..compat import compat_str, compat_urllib_parse_urlencode
from ..utils import (
int_or_none,
parse_iso8601,

Some files were not shown because too many files have changed in this diff Show more