Module stor
¶
Module responsible for downloading multimedia from Internet services. As for now only YouTube is supported.
-
class
ytfs.stor.
Downloader
[source]¶ Class responsible for data downloading. Every object similiar to
YTStor
can use it. (Currently no class, other than aforementionedYTStor
, is capable of usingDownloader
).-
static
fetch
(yts, needed_range, fh)[source]¶ Download desired range of data and put it in yts object (e.g.
YTStor
).Parameters: yts : YTStor
Stor-like object to which we will write.
needed_range : tuple
Two element tuple that represents a data range - compliant with
range_t
subrange definition.fh : int
Descriptor used by a process for filesystem operations.
Returns: None
Method does not return; data is written directly to yts object.
-
static
-
class
ytfs.stor.
YTMetaStor
(init_data, opts={})[source]¶ Class that holds metadata in a seperate file. Should always correspond to existing *Stor object, though this relation isn’t held anywhere in *Stor objects, they’ll just share a filename, but with different extensions.
-
class
ytfs.stor.
YTStor
(init_data, opts={})[source]¶ YTStor
- the heart of YTFS. Class responsible for obtaining and storing data and information about a movie of given id.Parameters: init_data : dict
Initial data object needed for further operation.
YTStor
needsyid
(str, YouTube video id) andpub_date
(video publication date as Unix timestamp).opts : dict
Options that will override globally set preferences.
Attributes
data (SpooledTemporaryFile) Temporary file object - actual data is stored here. lock (Lock) Lock to sync multiple threads. fds (set) Set of file descriptors assigned to the object. closing (bool) True
ifdata
is scheduled for closing.avail (range_t) Object saying how much data we have. filesize (int) Total data size. Not yet downloaded data is also considered. disk (int) How much data is cached on disk (8M factor). extension (str) File extension. rickastley (bool) Make every video rickroll r_session (requests.Session) Object that holds HTTP session. Thanks to that, we avoid useless TCP window size negotiations whenever we start a download. yid (str) YouTube id of a video which this object represents. preferences (dict) Current object preferences. url (str or tuple) Url to file. If tuple, then merging is needed; indices: 0: video, 1: audio.