hbmartin commited on
Commit
ebad199
·
1 Parent(s): ea14b7b

additional flake8 linters

Browse files
Files changed (3) hide show
  1. Pipfile +3 -0
  2. pytube/__main__.py +2 -3
  3. pytube/extract.py +2 -21
Pipfile CHANGED
@@ -21,11 +21,14 @@ flake8-executable = "*"
21
  flake8-if-expr = "*"
22
  flake8-isort = "*"
23
  flake8-logging-format = "*"
 
 
24
  flake8-print = "*"
25
  flake8-pytest = "*"
26
  flake8-pytest-style = "*"
27
  flake8-quotes = "*"
28
  flake8-return = "*"
 
29
  flake8-string-format = "*"
30
  mypy = "*"
31
  pep8-naming = "*"
 
21
  flake8-if-expr = "*"
22
  flake8-isort = "*"
23
  flake8-logging-format = "*"
24
+ flake8-mock = "*"
25
+ flake8-mutable = "*"
26
  flake8-print = "*"
27
  flake8-pytest = "*"
28
  flake8-pytest-style = "*"
29
  flake8-quotes = "*"
30
  flake8-return = "*"
31
+ flake8-strict = "*"
32
  flake8-string-format = "*"
33
  mypy = "*"
34
  pep8-naming = "*"
pytube/__main__.py CHANGED
@@ -76,10 +76,9 @@ class YouTube:
76
  # video_id part of /watch?v=<video_id>
77
  self.video_id = extract.video_id(url)
78
 
79
- # https://www.youtube.com/watch?v=<video_id>
80
- self.watch_url = extract.watch_url(self.video_id)
81
 
82
- self.embed_url = extract.embed_url(self.video_id)
83
  # A dictionary shared between all instances of :class:`Stream <Stream>`
84
  # (Borg pattern). Boooooo.
85
  self.stream_monostate = Monostate(
 
76
  # video_id part of /watch?v=<video_id>
77
  self.video_id = extract.video_id(url)
78
 
79
+ self.watch_url = f"https://youtube.com/watch?v={self.video_id}"
80
+ self.embed_url = f"https://www.youtube.com/embed/{self.video_id}"
81
 
 
82
  # A dictionary shared between all instances of :class:`Stream <Stream>`
83
  # (Borg pattern). Boooooo.
84
  self.stream_monostate = Monostate(
pytube/extract.py CHANGED
@@ -77,26 +77,6 @@ def video_id(url: str) -> str:
77
  return regex_search(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", url, group=1)
78
 
79
 
80
- def watch_url(video_id: str) -> str:
81
- """Construct a sanitized YouTube watch url, given a video id.
82
-
83
- :param str video_id:
84
- A YouTube video identifier.
85
- :rtype: str
86
- :returns:
87
- Sanitized YouTube watch url.
88
- """
89
- return "https://youtube.com/watch?v=" + video_id
90
-
91
-
92
- def embed_url(video_id: str) -> str:
93
- return f"https://www.youtube.com/embed/{video_id}"
94
-
95
-
96
- def eurl(video_id: str) -> str:
97
- return f"https://youtube.googleapis.com/v/{video_id}"
98
-
99
-
100
  def video_info_url(
101
  video_id: str, watch_url: str, embed_html: Optional[str], age_restricted: bool,
102
  ) -> str:
@@ -120,8 +100,9 @@ def video_info_url(
120
  sts = regex_search(r'"sts"\s*:\s*(\d+)', embed_html, group=1)
121
  # Here we use ``OrderedDict`` so that the output is consistent between
122
  # Python 2.7+.
 
123
  params = OrderedDict(
124
- [("video_id", video_id), ("eurl", eurl(video_id)), ("sts", sts),]
125
  )
126
  else:
127
  params = OrderedDict(
 
77
  return regex_search(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", url, group=1)
78
 
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  def video_info_url(
81
  video_id: str, watch_url: str, embed_html: Optional[str], age_restricted: bool,
82
  ) -> str:
 
100
  sts = regex_search(r'"sts"\s*:\s*(\d+)', embed_html, group=1)
101
  # Here we use ``OrderedDict`` so that the output is consistent between
102
  # Python 2.7+.
103
+ eurl = f"https://youtube.googleapis.com/v/{video_id}"
104
  params = OrderedDict(
105
+ [("video_id", video_id), ("eurl", eurl), ("sts", sts),]
106
  )
107
  else:
108
  params = OrderedDict(