hbmartin commited on
Commit
aba400f
·
1 Parent(s): 7e39439

update callback documentation

Browse files
Files changed (5) hide show
  1. README.md +3 -3
  2. pytube/__main__.py +2 -2
  3. pytube/cipher.py +1 -1
  4. pytube/cli.py +2 -2
  5. pytube/monostate.py +1 -1
README.md CHANGED
@@ -7,7 +7,7 @@
7
  <a href='https://pytube3.readthedocs.io/en/latest/?badge=latest'><img src='https://readthedocs.org/projects/pytube3/badge/?version=latest' alt='Documentation Status' /></a>
8
  <a href="https://codecov.io/gh/hbmartin/pytube3"><img src="https://codecov.io/gh/hbmartin/pytube3/branch/master/graph/badge.svg" /></a>
9
  <a href="https://www.codefactor.io/repository/github/hbmartin/pytube3/overview/master"><img src="https://www.codefactor.io/repository/github/hbmartin/pytube3/badge/master" alt="CodeFactor" /></a>
10
- <a href="https://gitter.im/pytube3/community"><img src="https://badges.gitter.im/pytube3.png" /></a>
11
  </p>
12
  </div>
13
 
@@ -207,7 +207,7 @@ Note: Using ``order_by`` on a given attribute will filter out all streams missin
207
  If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function:
208
 
209
  ```python
210
- >>> def convert_to_aac(stream, file_handler):
211
  return # do work
212
 
213
  >>> yt.register_on_complete_callback(convert_to_aac)
@@ -216,7 +216,7 @@ If your application requires post-processing logic, pytube allows you to specify
216
  Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well:
217
 
218
  ```python
219
- >>> def show_progress_bar(stream, chunk, file_handler, bytes_remaining):
220
  return # do work
221
 
222
  >>> yt.register_on_progress_callback(show_progress_bar)
 
7
  <a href='https://pytube3.readthedocs.io/en/latest/?badge=latest'><img src='https://readthedocs.org/projects/pytube3/badge/?version=latest' alt='Documentation Status' /></a>
8
  <a href="https://codecov.io/gh/hbmartin/pytube3"><img src="https://codecov.io/gh/hbmartin/pytube3/branch/master/graph/badge.svg" /></a>
9
  <a href="https://www.codefactor.io/repository/github/hbmartin/pytube3/overview/master"><img src="https://www.codefactor.io/repository/github/hbmartin/pytube3/badge/master" alt="CodeFactor" /></a>
10
+ <a href="https://gitter.im/pytube3/community"><img src="https://img.shields.io/badge/chat-gitter-lightgrey" /></a>
11
  </p>
12
  </div>
13
 
 
207
  If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function:
208
 
209
  ```python
210
+ >>> def convert_to_aac(stream: Stream, file_path: str):
211
  return # do work
212
 
213
  >>> yt.register_on_complete_callback(convert_to_aac)
 
216
  Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well:
217
 
218
  ```python
219
+ >>> def show_progress_bar(stream: Stream, chunk: bytes, bytes_remaining: int):
220
  return # do work
221
 
222
  >>> yt.register_on_progress_callback(show_progress_bar)
pytube/__main__.py CHANGED
@@ -317,7 +317,7 @@ class YouTube:
317
 
318
  :param callable func:
319
  A callback function that takes ``stream``, ``chunk``,
320
- ``file_handle``, ``bytes_remaining`` as parameters.
321
 
322
  :rtype: None
323
 
@@ -328,7 +328,7 @@ class YouTube:
328
  """Register a download complete callback function post initialization.
329
 
330
  :param callable func:
331
- A callback function that takes ``stream`` and ``file_handle``.
332
 
333
  :rtype: None
334
 
 
317
 
318
  :param callable func:
319
  A callback function that takes ``stream``, ``chunk``,
320
+ and ``bytes_remaining`` as parameters.
321
 
322
  :rtype: None
323
 
 
328
  """Register a download complete callback function post initialization.
329
 
330
  :param callable func:
331
+ A callback function that takes ``stream`` and ``file_path``.
332
 
333
  :rtype: None
334
 
pytube/cipher.py CHANGED
@@ -77,7 +77,7 @@ class Cipher:
77
 
78
  **Example**:
79
 
80
- >>> parse_function('DE.AJ(a,15)')
81
  ('AJ', 15)
82
 
83
  """
 
77
 
78
  **Example**:
79
 
80
+ parse_function('DE.AJ(a,15)')
81
  ('AJ', 15)
82
 
83
  """
pytube/cli.py CHANGED
@@ -11,7 +11,7 @@ import os
11
  import shutil
12
  import sys
13
  import subprocess # nosec
14
- from typing import Any, Optional, List
15
 
16
  from pytube import __version__, CaptionQuery, Stream, Playlist
17
  from pytube import YouTube
@@ -210,7 +210,7 @@ def display_progress_bar(
210
 
211
  # noinspection PyUnusedLocal
212
  def on_progress(
213
- stream: Any, chunk: bytes, bytes_remaining: int
214
  ) -> None: # pylint: disable=W0613
215
  filesize = stream.filesize
216
  bytes_received = filesize - bytes_remaining
 
11
  import shutil
12
  import sys
13
  import subprocess # nosec
14
+ from typing import List, Optional
15
 
16
  from pytube import __version__, CaptionQuery, Stream, Playlist
17
  from pytube import YouTube
 
210
 
211
  # noinspection PyUnusedLocal
212
  def on_progress(
213
+ stream: Stream, chunk: bytes, bytes_remaining: int
214
  ) -> None: # pylint: disable=W0613
215
  filesize = stream.filesize
216
  bytes_received = filesize - bytes_remaining
pytube/monostate.py CHANGED
@@ -12,7 +12,7 @@ class OnProgress(Protocol):
12
  An instance of :class:`Stream <Stream>` being downloaded.
13
  :type stream:
14
  :py:class:`pytube.Stream`
15
- :param str chunk:
16
  Segment of media file binary data, not yet written to disk.
17
  :param int bytes_remaining:
18
  How many bytes have been downloaded.
 
12
  An instance of :class:`Stream <Stream>` being downloaded.
13
  :type stream:
14
  :py:class:`pytube.Stream`
15
+ :param bytes chunk:
16
  Segment of media file binary data, not yet written to disk.
17
  :param int bytes_remaining:
18
  How many bytes have been downloaded.