Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
obj1, obj2 (media.Video, media.Channel, media.Playlist or
media.Folder) - Media data objects being sorted
Returns:
-1 if obj1 comes first, 1 if obj2 comes first, 0 if they are equal
"""
if str(obj1.__class__) == str(obj2.__class__) \
or (
isinstance(obj1, GenericRemoteContainer) \
and isinstance(obj2, GenericRemoteContainer)
):
if isinstance(obj1, Video):
# Livestreams come before everything else
if obj1.live_mode > obj2.live_mode:
return -1
elif obj1.live_mode < obj2.live_mode:
return 1
# Otherwise sort by upload time, then by receive time
elif obj1.upload_time is not None \
and obj2.upload_time is not None:
if obj1.upload_time > obj2.upload_time:
return -1
elif obj1.upload_time < obj2.upload_time:
return 1
# def get_relative_actual_dir(): # Inherited from GenericContainer
# def get_relative_default_dir(): # Inherited from GenericContainer
def never_called_func(self):
"""Function that is never called, but which makes this class object
collapse neatly in my IDE."""
pass
class Playlist(GenericRemoteContainer):
"""Python class that handles a playlist (e.g. on YouTube).
Args:
app_obj (mainapp.TartubeApp): The main application (not stored as an
IV)
dbid (int): A unique ID for this media data object
name (str) - The playlist name
parent_obj (media.Folder) - The parent media data object, if any
options_obj (options.OptionsManager) - The object specifying download
options for this channel, if any
Converts self.upload_time, in Unix time, into a formatted string.
Returns:
The formatted string, or None if self.upload_time is not set
"""
if self.upload_time:
return str(datetime.datetime.fromtimestamp(self.upload_time))
else:
return None
class Channel(GenericRemoteContainer):
"""Python class that handles a channel (e.g. on YouTube).
Args:
app_obj (mainapp.TartubeApp): The main application (not stored as an
IV)
dbid (int): A unique ID for this media data object
name (str) - The channel name
parent_obj (media.Folder) - The parent media data object, if any
options_obj (options.OptionsManager) - The object specifying download
options for this channel, if any