drop support for python 2 and 3.4
Browse files- .travis.yml +2 -6
- Pipfile +1 -1
- docs/api.rst +0 -6
- pytube/__main__.py +2 -2
- pytube/captions.py +1 -2
- pytube/compat.py +0 -72
- pytube/extract.py +3 -3
- pytube/helpers.py +1 -2
- pytube/mixins.py +9 -3
- pytube/request.py +3 -4
- setup.cfg +0 -2
- setup.py +1 -3
.travis.yml
CHANGED
@@ -3,13 +3,9 @@ cache:
|
|
3 |
- apt
|
4 |
- pip
|
5 |
python:
|
6 |
-
- "2.7"
|
7 |
-
- "3.4"
|
8 |
- "3.5"
|
9 |
-
- "3.5-dev" # 3.5 development branch
|
10 |
- "3.6"
|
11 |
-
- "3.
|
12 |
-
- "3.7-dev" # 3.7 development branch
|
13 |
install: "make"
|
14 |
script:
|
15 |
- make ci
|
@@ -19,4 +15,4 @@ sudo: false
|
|
19 |
after_success:
|
20 |
coveralls
|
21 |
notifications:
|
22 |
-
slack: watchcloud:rNoT5kJJakPqwLSKuev6oa4C
|
|
|
3 |
- apt
|
4 |
- pip
|
5 |
python:
|
|
|
|
|
6 |
- "3.5"
|
|
|
7 |
- "3.6"
|
8 |
+
- "3.7"
|
|
|
9 |
install: "make"
|
10 |
script:
|
11 |
- make ci
|
|
|
15 |
after_success:
|
16 |
coveralls
|
17 |
notifications:
|
18 |
+
# slack: watchcloud:rNoT5kJJakPqwLSKuev6oa4C
|
Pipfile
CHANGED
@@ -21,4 +21,4 @@ twine = "*"
|
|
21 |
more-itertools = "==5.0.0"
|
22 |
|
23 |
[requires]
|
24 |
-
python_version = "3.
|
|
|
21 |
more-itertools = "==5.0.0"
|
22 |
|
23 |
[requires]
|
24 |
+
python_version = "3.7"
|
docs/api.rst
CHANGED
@@ -65,12 +65,6 @@ Mixins
|
|
65 |
.. automodule:: pytube.mixins
|
66 |
:members:
|
67 |
|
68 |
-
Compat
|
69 |
-
------
|
70 |
-
|
71 |
-
.. automodule:: pytube.compat
|
72 |
-
:members:
|
73 |
-
|
74 |
|
75 |
Helpers
|
76 |
-------
|
|
|
65 |
.. automodule:: pytube.mixins
|
66 |
:members:
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
Helpers
|
70 |
-------
|
pytube/__main__.py
CHANGED
@@ -11,6 +11,7 @@ from __future__ import absolute_import
|
|
11 |
|
12 |
import json
|
13 |
import logging
|
|
|
14 |
|
15 |
from pytube import Caption
|
16 |
from pytube import CaptionQuery
|
@@ -19,8 +20,7 @@ from pytube import mixins
|
|
19 |
from pytube import request
|
20 |
from pytube import Stream
|
21 |
from pytube import StreamQuery
|
22 |
-
from pytube.
|
23 |
-
from pytube.compat import parse_qsl
|
24 |
from pytube.exceptions import VideoUnavailable
|
25 |
from pytube.helpers import apply_mixin
|
26 |
|
|
|
11 |
|
12 |
import json
|
13 |
import logging
|
14 |
+
from urllib.parse import parse_qsl
|
15 |
|
16 |
from pytube import Caption
|
17 |
from pytube import CaptionQuery
|
|
|
20 |
from pytube import request
|
21 |
from pytube import Stream
|
22 |
from pytube import StreamQuery
|
23 |
+
from pytube.mixins import install_proxy
|
|
|
24 |
from pytube.exceptions import VideoUnavailable
|
25 |
from pytube.helpers import apply_mixin
|
26 |
|
pytube/captions.py
CHANGED
@@ -5,8 +5,7 @@ import time
|
|
5 |
import xml.etree.ElementTree as ElementTree
|
6 |
|
7 |
from pytube import request
|
8 |
-
from
|
9 |
-
|
10 |
|
11 |
class Caption:
|
12 |
"""Container for caption tracks."""
|
|
|
5 |
import xml.etree.ElementTree as ElementTree
|
6 |
|
7 |
from pytube import request
|
8 |
+
from html import unescape
|
|
|
9 |
|
10 |
class Caption:
|
11 |
"""Container for caption tracks."""
|
pytube/compat.py
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python
|
2 |
-
# -*- coding: utf-8 -*-
|
3 |
-
# flake8: noqa
|
4 |
-
"""Python 2/3 compatibility support."""
|
5 |
-
import sys
|
6 |
-
|
7 |
-
|
8 |
-
PY2 = sys.version_info[0] == 2
|
9 |
-
PY3 = sys.version_info[0] == 3
|
10 |
-
PY33 = sys.version_info[0:2] >= (3, 3)
|
11 |
-
|
12 |
-
if PY2:
|
13 |
-
reload(sys)
|
14 |
-
sys.setdefaultencoding('utf8')
|
15 |
-
import urllib2
|
16 |
-
from urllib import urlencode
|
17 |
-
from urllib2 import URLError
|
18 |
-
from urllib2 import quote
|
19 |
-
from urllib2 import unquote
|
20 |
-
from urllib2 import urlopen
|
21 |
-
from urlparse import parse_qsl
|
22 |
-
from urlparse import parse_qs
|
23 |
-
from HTMLParser import HTMLParser
|
24 |
-
|
25 |
-
def install_proxy(proxy_handler):
|
26 |
-
"""
|
27 |
-
install global proxy.
|
28 |
-
:param proxy_handler:
|
29 |
-
:samp:`{"http":"http://my.proxy.com:1234", "https":"https://my.proxy.com:1234"}`
|
30 |
-
:return:
|
31 |
-
"""
|
32 |
-
proxy_support = urllib2.ProxyHandler(proxy_handler)
|
33 |
-
opener = urllib2.build_opener(proxy_support)
|
34 |
-
urllib2.install_opener(opener)
|
35 |
-
|
36 |
-
def unescape(s):
|
37 |
-
"""Strip HTML entries from a string."""
|
38 |
-
html_parser = HTMLParser()
|
39 |
-
return html_parser.unescape(s)
|
40 |
-
|
41 |
-
def unicode(s):
|
42 |
-
"""Encode a string to utf-8."""
|
43 |
-
return s.encode('utf-8')
|
44 |
-
|
45 |
-
elif PY3:
|
46 |
-
from urllib.error import URLError
|
47 |
-
from urllib.parse import parse_qsl
|
48 |
-
from urllib.parse import parse_qs
|
49 |
-
from urllib.parse import quote
|
50 |
-
from urllib.parse import unquote
|
51 |
-
from urllib.parse import urlencode
|
52 |
-
from urllib.request import urlopen
|
53 |
-
from urllib import request
|
54 |
-
|
55 |
-
def install_proxy(proxy_handler):
|
56 |
-
proxy_support = request.ProxyHandler(proxy_handler)
|
57 |
-
opener = request.build_opener(proxy_support)
|
58 |
-
request.install_opener(opener)
|
59 |
-
|
60 |
-
def unicode(s):
|
61 |
-
"""No-op."""
|
62 |
-
return s
|
63 |
-
|
64 |
-
if PY33:
|
65 |
-
from html.parser import HTMLParser
|
66 |
-
|
67 |
-
def unescape(s):
|
68 |
-
"""Strip HTML entries from a string."""
|
69 |
-
html_parser = HTMLParser()
|
70 |
-
return html_parser.unescape(s)
|
71 |
-
else:
|
72 |
-
from html import unescape
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pytube/extract.py
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
import json
|
4 |
from collections import OrderedDict
|
5 |
|
6 |
-
from
|
7 |
-
from
|
8 |
-
from
|
9 |
from pytube.exceptions import RegexMatchError
|
10 |
from pytube.helpers import regex_search
|
11 |
|
|
|
3 |
import json
|
4 |
from collections import OrderedDict
|
5 |
|
6 |
+
from html.parser import HTMLParser
|
7 |
+
from urllib.parse import quote
|
8 |
+
from urllib.parse import urlencode
|
9 |
from pytube.exceptions import RegexMatchError
|
10 |
from pytube.helpers import regex_search
|
11 |
|
pytube/helpers.py
CHANGED
@@ -6,7 +6,6 @@ import logging
|
|
6 |
import pprint
|
7 |
import re
|
8 |
|
9 |
-
from pytube.compat import unicode
|
10 |
from pytube.exceptions import RegexMatchError
|
11 |
|
12 |
|
@@ -124,4 +123,4 @@ def safe_filename(s, max_length=255):
|
|
124 |
pattern = '|'.join(ntfs_chrs + chrs)
|
125 |
regex = re.compile(pattern, re.UNICODE)
|
126 |
filename = regex.sub('', s)
|
127 |
-
return
|
|
|
6 |
import pprint
|
7 |
import re
|
8 |
|
|
|
9 |
from pytube.exceptions import RegexMatchError
|
10 |
|
11 |
|
|
|
123 |
pattern = '|'.join(ntfs_chrs + chrs)
|
124 |
regex = re.compile(pattern, re.UNICODE)
|
125 |
filename = regex.sub('', s)
|
126 |
+
return filename[:max_length].rsplit(' ', 0)[0]
|
pytube/mixins.py
CHANGED
@@ -7,9 +7,10 @@ import logging
|
|
7 |
import pprint
|
8 |
|
9 |
from pytube import cipher
|
10 |
-
from
|
11 |
-
from
|
12 |
-
from
|
|
|
13 |
from pytube.exceptions import LiveStreamError
|
14 |
|
15 |
|
@@ -117,3 +118,8 @@ def apply_descrambler(stream_data, key):
|
|
117 |
'applying descrambler\n%s',
|
118 |
pprint.pformat(stream_data[key], indent=2),
|
119 |
)
|
|
|
|
|
|
|
|
|
|
|
|
7 |
import pprint
|
8 |
|
9 |
from pytube import cipher
|
10 |
+
from urllib import request
|
11 |
+
from urllib.parse import parse_qsl
|
12 |
+
from urllib.parse import parse_qs
|
13 |
+
from urllib.parse import unquote
|
14 |
from pytube.exceptions import LiveStreamError
|
15 |
|
16 |
|
|
|
118 |
'applying descrambler\n%s',
|
119 |
pprint.pformat(stream_data[key], indent=2),
|
120 |
)
|
121 |
+
|
122 |
+
def install_proxy(proxy_handler):
|
123 |
+
proxy_support = request.ProxyHandler(proxy_handler)
|
124 |
+
opener = request.build_opener(proxy_support)
|
125 |
+
request.install_opener(opener)
|
pytube/request.py
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
"""Implements a simple wrapper around urlopen."""
|
3 |
-
|
4 |
-
|
5 |
-
from pytube.compat import urlopen
|
6 |
# 403 forbidden fix
|
7 |
|
8 |
|
@@ -23,7 +22,7 @@ def get(
|
|
23 |
"""
|
24 |
|
25 |
# https://github.com/nficano/pytube/pull/465
|
26 |
-
req =
|
27 |
response = urlopen(req)
|
28 |
|
29 |
if streaming:
|
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
"""Implements a simple wrapper around urlopen."""
|
3 |
+
from urllib.request import Request
|
4 |
+
from urllib.request import urlopen
|
|
|
5 |
# 403 forbidden fix
|
6 |
|
7 |
|
|
|
22 |
"""
|
23 |
|
24 |
# https://github.com/nficano/pytube/pull/465
|
25 |
+
req = Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
26 |
response = urlopen(req)
|
27 |
|
28 |
if streaming:
|
setup.cfg
CHANGED
@@ -15,8 +15,6 @@ description-file = README.md
|
|
15 |
|
16 |
[coverage:run]
|
17 |
source = pytube
|
18 |
-
omit =
|
19 |
-
pytube/compat.py
|
20 |
|
21 |
[flake8]
|
22 |
ignore = W605
|
|
|
15 |
|
16 |
[coverage:run]
|
17 |
source = pytube
|
|
|
|
|
18 |
|
19 |
[flake8]
|
20 |
ignore = W605
|
setup.py
CHANGED
@@ -54,7 +54,7 @@ setup(
|
|
54 |
package_data={
|
55 |
'': ['LICENSE'],
|
56 |
},
|
57 |
-
url='https://github.com/
|
58 |
license='MIT',
|
59 |
entry_points={
|
60 |
'console_scripts': [
|
@@ -71,8 +71,6 @@ setup(
|
|
71 |
'Operating System :: Microsoft',
|
72 |
'Operating System :: POSIX',
|
73 |
'Operating System :: Unix',
|
74 |
-
'Programming Language :: Python :: 2.7',
|
75 |
-
'Programming Language :: Python :: 3.4',
|
76 |
'Programming Language :: Python :: 3.5',
|
77 |
'Programming Language :: Python :: 3.6',
|
78 |
'Programming Language :: Python :: 3.7',
|
|
|
54 |
package_data={
|
55 |
'': ['LICENSE'],
|
56 |
},
|
57 |
+
url='https://github.com/hbmartin/pytube',
|
58 |
license='MIT',
|
59 |
entry_points={
|
60 |
'console_scripts': [
|
|
|
71 |
'Operating System :: Microsoft',
|
72 |
'Operating System :: POSIX',
|
73 |
'Operating System :: Unix',
|
|
|
|
|
74 |
'Programming Language :: Python :: 3.5',
|
75 |
'Programming Language :: Python :: 3.6',
|
76 |
'Programming Language :: Python :: 3.7',
|