hbmartin commited on
Commit
5afc31c
·
1 Parent(s): 3948e64

rename to descramble

Browse files
docs/index.rst CHANGED
@@ -1,7 +1,4 @@
1
- .. pytube3 documentation master file, created by
2
- sphinx-quickstart on Mon Oct 9 02:11:41 2017.
3
- You can adapt this file completely to your liking, but it should at least
4
- contain the root `toctree` directive.
5
 
6
  pytube3
7
  ======
@@ -29,6 +26,7 @@ Release v\ |version|. (:ref:`Installation <install>`)
29
 
30
  **Behold, a perfect balance of simplicity versus flexibility**::
31
 
 
32
  >>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
33
  >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
34
  >>> yt.streams
 
1
+ .. pytube3 documentation master file, created by sphinx-quickstart on Mon Oct 9 02:11:41 2017.
 
 
 
2
 
3
  pytube3
4
  ======
 
26
 
27
  **Behold, a perfect balance of simplicity versus flexibility**::
28
 
29
+ >>> from pytube import YouTube
30
  >>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download()
31
  >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0')
32
  >>> yt.streams
pytube/__main__.py CHANGED
@@ -42,7 +42,7 @@ class YouTube(object):
42
 
43
  :param str url:
44
  A valid YouTube watch URL.
45
- :param bool defer_init:
46
  Defers executing any network requests.
47
  :param func on_progress_callback:
48
  (Optional) User defined callback function for stream download
@@ -89,18 +89,18 @@ class YouTube(object):
89
  install_proxy(proxies)
90
 
91
  if not defer_prefetch_init:
92
- self.prefetch_init()
93
 
94
- def prefetch_init(self):
95
  """Download data, descramble it, and build Stream instances.
96
 
97
  :rtype: None
98
 
99
  """
100
  self.prefetch()
101
- self.init()
102
 
103
- def init(self):
104
  """Descramble the stream data and build Stream instances.
105
 
106
  The initialization process takes advantage of Python's
 
42
 
43
  :param str url:
44
  A valid YouTube watch URL.
45
+ :param bool defer_prefetch_init:
46
  Defers executing any network requests.
47
  :param func on_progress_callback:
48
  (Optional) User defined callback function for stream download
 
89
  install_proxy(proxies)
90
 
91
  if not defer_prefetch_init:
92
+ self.prefetch_descramble()
93
 
94
+ def prefetch_descramble(self):
95
  """Download data, descramble it, and build Stream instances.
96
 
97
  :rtype: None
98
 
99
  """
100
  self.prefetch()
101
+ self.descramble()
102
 
103
+ def descramble(self):
104
  """Descramble the stream data and build Stream instances.
105
 
106
  The initialization process takes advantage of Python's
tests/conftest.py CHANGED
@@ -27,7 +27,7 @@ def load_and_init_from_playback_file(filename):
27
  yt.watch_html = pb['watch_html']
28
  yt.js = pb['js']
29
  yt.vid_info = pb['video_info']
30
- yt.init()
31
  return yt
32
 
33
 
 
27
  yt.watch_html = pb['watch_html']
28
  yt.js = pb['js']
29
  yt.vid_info = pb['video_info']
30
+ yt.descramble()
31
  return yt
32
 
33
 
tests/contrib/__pycache__/tmpgekc8jvs DELETED
Binary file (1.36 kB)
 
tests/test_cli.py CHANGED
@@ -8,6 +8,6 @@ from pytube import cli
8
  @mock.patch('pytube.cli.sys')
9
  def test_download(MockYouTube, mock_sys):
10
  instance = MockYouTube.return_value
11
- instance.prefetch_init.return_value = None
12
  instance.streams = mock.Mock()
13
  cli.download('asdf', 'asdf')
 
8
  @mock.patch('pytube.cli.sys')
9
  def test_download(MockYouTube, mock_sys):
10
  instance = MockYouTube.return_value
11
+ instance.prefetch_descramble.return_value = None
12
  instance.streams = mock.Mock()
13
  cli.download('asdf', 'asdf')
tests/test_main.py CHANGED
@@ -7,6 +7,6 @@ from pytube import YouTube
7
  @mock.patch('pytube.__main__.YouTube')
8
  def test_prefetch_deferred(MockYouTube):
9
  instance = MockYouTube.return_value
10
- instance.prefetch_init.return_value = None
11
  YouTube('https://www.youtube.com/watch?v=9bZkp7q19f0', True)
12
- assert not instance.prefetch_init.called
 
7
  @mock.patch('pytube.__main__.YouTube')
8
  def test_prefetch_deferred(MockYouTube):
9
  instance = MockYouTube.return_value
10
+ instance.prefetch_descramble.return_value = None
11
  YouTube('https://www.youtube.com/watch?v=9bZkp7q19f0', True)
12
+ assert not instance.prefetch_descramble.called