monostate.py
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from typing import Any
from typing import Optional
class OnProgress():
def __call__(
self, stream: Any, chunk: bytes, bytes_remaining: int
) -> None:
"""On download progress callback function.
:param stream:
An instance of :class:`Stream <Stream>` being downloaded.
:type stream:
:py:class:`pytube.Stream`
:param bytes chunk:
Segment of media file binary data, not yet written to disk.
:param int bytes_remaining:
How many bytes have been downloaded.
"""
...
class OnComplete():
def __call__(self, stream: Any, file_path: Optional[str]) -> None:
"""On download complete handler function.
:param stream:
An instance of :class:`Stream <Stream>` being downloaded.
:type stream:
:py:class:`pytube.Stream`
:param file_path:
The file handle where the media is being written to.
:type file_path: str
:rtype: None
"""
...
class Monostate:
def __init__(
self,
on_progress: Optional[OnProgress],
on_complete: Optional[OnComplete],
title: Optional[str] = None,
duration: Optional[int] = None,
):
self.on_progress = on_progress
self.on_complete = on_complete
self.title = title
self.duration = duration