Skip to content

types ¤

Custom types for TVSD

Episode ¤

Episode(
    episode_name: str, episode_url: str, season: Season
)

A class representing an episode of a TV show.

Attributes:

  • _name (str) –

    The name of the episode.

  • _url (str) –

    The URL of the episode.

  • _number (int) –

    The episode number.

  • _season (Season) –

    The season that the episode belongs to.

  • _not_specials (bool) –

    True if the episode is not a special episode, False otherwise.

Parameters:

  • episode_name (str) –

    The name of the episode.

  • episode_url (str) –

    The URL of the episode.

  • season (Season) –

    The season that this episode belongs to.

determine_episode_number property ¤

determine_episode_number: int

Determines the episode number.

This method determines the episode number by either incrementing the previous episode number by 1 or by identifying the episode number from the episode name. The episode number is then stored in the instance variable _number.

Returns:

  • int ( int ) –

    The episode number.

episode_number property writable ¤

episode_number: int

Returns the episode number.

If the episode number is not already set, it will be identified from the episode name.

Returns:

  • int ( int ) –

    The episode number.

fetch_episode_m3u8_url property ¤

fetch_episode_m3u8_url: str

Fetches the m3u8 url of the episode.

This method fetches the m3u8 url of the episode by calling the fetch_episode_m3u8 method of the season's source object, passing in the relative episode url as a parameter. If the m3u8 url is not found, an empty string is returned.

Returns:

  • str ( str ) –

    The m3u8 url of the episode.

file_exists_locally property ¤

file_exists_locally: str

Returns the name of the existing file if the episode exists locally, or an empty string otherwise.

Returns:

  • filename ( str ) –

    Name of existing file if the episode exists locally, Empty String otherwise.

filename property ¤

filename: str

Returns the filename of the episode.

The filename is formatted as follows: {show_prefix} - S{season_index}E{episode_number} - {episode_name}

Returns:

  • str ( str ) –

    The filename of the episode.

get_episode_url property ¤

get_episode_url: str

Gets the episode url from the episode object.

This method returns the url of the episode object.

Returns:

  • str ( str ) –

    The episode url.

is_regular property ¤

is_regular: bool

Returns True if the episode is a regular episode, False otherwise.

Returns:

  • bool ( bool ) –

    True if the episode is a regular episode, False otherwise.

is_specials property ¤

is_specials: bool

Returns True if the episode is a special episode, False otherwise.

Returns:

  • bool ( bool ) –

    True if the episode is a special episode, False otherwise.

name property ¤

name: str

Returns the episode name.

This method returns the name of the episode.

Returns:

  • str ( str ) –

    The episode name.

relative_destination_dir property ¤

relative_destination_dir: str

Returns the relative destination directory of the episode.

If the episode is a special episode, the relative destination directory will be the relative specials directory of the season. Otherwise, it will be the relative season directory of the season.

Returns:

  • str ( str ) –

    The relative destination directory of the episode.

relative_episode_file_path property ¤

relative_episode_file_path: str

Returns the relative path to the episode file.

The returned path is relative to the root directory of the TVSD project.

Returns:

  • str ( str ) –

    The relative path to the episode file.

season property ¤

season: Season

Returns the season object.

Returns:

  • Season ( Season ) –

    The season object.

__repr__ ¤

__repr__() -> str

Returns a string representation of the Episode object. The string contains the name and episode number of the episode.

__str__ ¤

__str__() -> str

Returns a string representation of the Episode object.

The string representation includes the name and episode number of the episode.

Returns:

  • str ( str ) –

    A string representation of the Episode object.

determine_if_specials ¤

determine_if_specials() -> bool

Determines if the episode is a special episode from episode title.

Returns:

  • bool ( bool ) –

    True if the episode is a special episode, False otherwise.

identify_episode_number_from_name ¤

identify_episode_number_from_name() -> int

Tries to identify the episode number from the episode name.

This function uses a regular expression to identify the episode number from the episode name. If the episode number is found, it is returned as an integer. If it is not found, the function returns 1.

Returns:

  • int ( int ) –

    The identified episode number.

EpisodeDetailsFromURL ¤

Bases: TypedDict

DetailsFromURL type object

Attributes:

  • title (str) –

    The title of the episode

  • url (str) –

    The URL of the episode

Season ¤

Season(
    fetch_episode_m3u8: Callable,
    episodes: List[Episode],
    details: SeasonDetailsFromURL,
    source: Source,
    note: str = "",
    details_url: str = "",
)

Represents a season of a TV show.

Attributes:

Parameters:

  • fetch_episode_m3u8 (Callable) –

    A callable function that fetches the m3u8 file for an episode.

  • episodes (List[Episode]) –

    A list of Episode objects.

  • details (SeasonDetailsFromURL) –

    A dictionary containing details about the season.

  • source (Source) –

    A Source object representing the source of the season.

  • note (str, default: '' ) –

    A note about the season. Defaults to "".

  • details_url (str, default: '' ) –

    The URL of the page containing details about the season. Defaults to "".

description property ¤

description: str

Returns the description of the season

Returns:

  • str ( str ) –

    description of the season

details_url property writable ¤

details_url: str

Returns the details url of the season

Returns:

  • str ( str ) –

    details url of the season

episodes property ¤

episodes: List[Episode]

Returns the list of episodes in the season.

Returns:

  • List[Episode]

    List[Episode]: A list of Episode objects representing the episodes in the season.

note property writable ¤

note: str

Get the note of the show

This method returns the note of the show.

Returns:

  • str ( str ) –

    Note of the show

relative_season_dir property ¤

relative_season_dir: str

Returns the relative directory for the current season.

If the season index is 0, the relative specials directory is returned. Otherwise, the relative directory for the current season is returned.

Returns:

  • str ( str ) –

    The relative directory for the current season.

relative_specials_dir property ¤

relative_specials_dir: str

Returns the relative specials directory

This method returns the relative directory for the specials of the season.

Returns:

  • str ( str ) –

    relative specials directory

season_index property ¤

season_index: int

Returns the season index

This method returns the index of the season. If the index has not been set yet, it will be determined based on the title of the season. If the title does not contain a season index, the default index of 1 will be returned.

Returns:

  • int ( int ) –

    season index

show property ¤

show: Show

Returns the show of the season

Returns:

  • Show ( Show ) –

    show of the season

source property ¤

source: Source

Returns the source of the season

Returns:

  • Source ( Source ) –

    source of the season

title property ¤

title: str

Returns the title of the season

Returns:

  • str ( str ) –

    title of the season

year property ¤

year: str

Returns the year of the season

Returns:

  • str ( str ) –

    year of the season

create_show ¤

create_show() -> Show

Create a parent show for this season.

This method creates a parent show for the current season object. The parent show is created using the source type, title, and beginning year of the current season. The created show is then returned.

Returns:

  • Show ( Show ) –

    The created parent show.

determine_season_index ¤

determine_season_index(season_title: str) -> int

Determines season index from title of season

Parameters:

  • season_title (str) –

    Title of the season to query with. Defaults to None.

Returns:

  • int ( int ) –

    index of season

determine_show_begin_year ¤

determine_show_begin_year() -> str

Query the begin year of the show

This method determines the begin year of the show based on the season's year and index. If the season index is greater than 1, it prompts the user to input the year of the first season.

Returns:

  • str ( str ) –

    Begin year of the show as a string

fetch_details ¤

fetch_details() -> None

Fetch details for season for download.

This method creates a show, generates episodes, and fetches details for the season to prepare for download.

generate_episodes ¤

generate_episodes() -> None

Generate Episode objects for the season.

This method generates Episode objects for the season based on the list of episodes associated with the season. If an episode in the list is already an Episode object, it is added to the list of generated Episode objects. If an episode in the list is not an Episode object, its details are parsed from the source and a new Episode object is created and added to the list of generated Episode objects.

Returns:

  • None

    None

SeasonDetailsFromURL ¤

Bases: TypedDict

DetailsFromURL type object

Attributes:

  • title (str) –

    The title of the season.

  • description (str) –

    The description of the season.

  • episodes (List[Episode]) –

    A list of Episode objects representing the episodes in the season.

  • year (str) –

    The year the season was released.

Show ¤

Show(source: Source, title: str = '', begin_year: str = '')

Represents a TV show.

Attributes:

  • _title (str) –

    The title of the show.

  • _source (Source) –

    The source of the show.

  • _seasons (List[Season]) –

    The seasons of the show.

  • _begin_year (str) –

    The year the show began.

  • _prefix (str) –

    The directory name of the show.

Parameters:

  • source (Source) –

    The source of the show.

  • title (str, default: '' ) –

    The title of the show. Defaults to "".

  • begin_year (str, default: '' ) –

    The year the show began. Defaults to "".

begin_year property ¤

begin_year: str

Returns the begin year of the show

Returns:

  • str ( str ) –

    begin year of the show

relative_show_dir property ¤

relative_show_dir: str

Get the relative directory of the show in the media directory from the base path.

This method returns the relative directory of the show in the media directory from the base path.

Returns:

  • str ( str ) –

    The relative directory of the show in the media directory from the base path.

seasons property ¤

seasons: List[Season]

Returns a list of all the seasons of the show.

Returns:

  • List[Season]

    List[Season]: A list of all the seasons of the show.

show_prefix property ¤

show_prefix: str

Returns the show prefix, which is the directory name of the show.

If the show prefix has already been set, it will be returned. Otherwise, it will be generated using the generate_show_prefix method.

Returns:

  • str ( str ) –

    The show prefix (the directory name of the show).

source property ¤

source: str

Getter method for the source of the current Show.

Returns:

  • str ( str ) –

    The source of the current Show.

title property writable ¤

title: str

Get the title of the show

This method returns the title of the show.

Returns:

  • str ( str ) –

    Title of the show

generate_show_prefix ¤

generate_show_prefix() -> str

Generate the prefix for the show.

The prefix is the directory name of the show, and is generated by combining the show's title and beginning year.

Returns:

  • str ( str ) –

    The prefix for the show.

episode ¤

Episode class.

Episode ¤

Episode(
    episode_name: str, episode_url: str, season: Season
)

A class representing an episode of a TV show.

Attributes:

  • _name (str) –

    The name of the episode.

  • _url (str) –

    The URL of the episode.

  • _number (int) –

    The episode number.

  • _season (Season) –

    The season that the episode belongs to.

  • _not_specials (bool) –

    True if the episode is not a special episode, False otherwise.

Parameters:

  • episode_name (str) –

    The name of the episode.

  • episode_url (str) –

    The URL of the episode.

  • season (Season) –

    The season that this episode belongs to.

determine_episode_number property ¤

determine_episode_number: int

Determines the episode number.

This method determines the episode number by either incrementing the previous episode number by 1 or by identifying the episode number from the episode name. The episode number is then stored in the instance variable _number.

Returns:

  • int ( int ) –

    The episode number.

episode_number property writable ¤

episode_number: int

Returns the episode number.

If the episode number is not already set, it will be identified from the episode name.

Returns:

  • int ( int ) –

    The episode number.

fetch_episode_m3u8_url property ¤

fetch_episode_m3u8_url: str

Fetches the m3u8 url of the episode.

This method fetches the m3u8 url of the episode by calling the fetch_episode_m3u8 method of the season's source object, passing in the relative episode url as a parameter. If the m3u8 url is not found, an empty string is returned.

Returns:

  • str ( str ) –

    The m3u8 url of the episode.

file_exists_locally property ¤

file_exists_locally: str

Returns the name of the existing file if the episode exists locally, or an empty string otherwise.

Returns:

  • filename ( str ) –

    Name of existing file if the episode exists locally, Empty String otherwise.

filename property ¤

filename: str

Returns the filename of the episode.

The filename is formatted as follows: {show_prefix} - S{season_index}E{episode_number} - {episode_name}

Returns:

  • str ( str ) –

    The filename of the episode.

get_episode_url property ¤

get_episode_url: str

Gets the episode url from the episode object.

This method returns the url of the episode object.

Returns:

  • str ( str ) –

    The episode url.

is_regular property ¤

is_regular: bool

Returns True if the episode is a regular episode, False otherwise.

Returns:

  • bool ( bool ) –

    True if the episode is a regular episode, False otherwise.

is_specials property ¤

is_specials: bool

Returns True if the episode is a special episode, False otherwise.

Returns:

  • bool ( bool ) –

    True if the episode is a special episode, False otherwise.

name property ¤

name: str

Returns the episode name.

This method returns the name of the episode.

Returns:

  • str ( str ) –

    The episode name.

relative_destination_dir property ¤

relative_destination_dir: str

Returns the relative destination directory of the episode.

If the episode is a special episode, the relative destination directory will be the relative specials directory of the season. Otherwise, it will be the relative season directory of the season.

Returns:

  • str ( str ) –

    The relative destination directory of the episode.

relative_episode_file_path property ¤

relative_episode_file_path: str

Returns the relative path to the episode file.

The returned path is relative to the root directory of the TVSD project.

Returns:

  • str ( str ) –

    The relative path to the episode file.

season property ¤

season: Season

Returns the season object.

Returns:

  • Season ( Season ) –

    The season object.

__repr__ ¤

__repr__() -> str

Returns a string representation of the Episode object. The string contains the name and episode number of the episode.

__str__ ¤

__str__() -> str

Returns a string representation of the Episode object.

The string representation includes the name and episode number of the episode.

Returns:

  • str ( str ) –

    A string representation of the Episode object.

determine_if_specials ¤

determine_if_specials() -> bool

Determines if the episode is a special episode from episode title.

Returns:

  • bool ( bool ) –

    True if the episode is a special episode, False otherwise.

identify_episode_number_from_name ¤

identify_episode_number_from_name() -> int

Tries to identify the episode number from the episode name.

This function uses a regular expression to identify the episode number from the episode name. If the episode number is found, it is returned as an integer. If it is not found, the function returns 1.

Returns:

  • int ( int ) –

    The identified episode number.

season ¤

TVSD Season class, parent of Episodes

Season ¤

Season(
    fetch_episode_m3u8: Callable,
    episodes: List[Episode],
    details: SeasonDetailsFromURL,
    source: Source,
    note: str = "",
    details_url: str = "",
)

Represents a season of a TV show.

Attributes:

Parameters:

  • fetch_episode_m3u8 (Callable) –

    A callable function that fetches the m3u8 file for an episode.

  • episodes (List[Episode]) –

    A list of Episode objects.

  • details (SeasonDetailsFromURL) –

    A dictionary containing details about the season.

  • source (Source) –

    A Source object representing the source of the season.

  • note (str, default: '' ) –

    A note about the season. Defaults to "".

  • details_url (str, default: '' ) –

    The URL of the page containing details about the season. Defaults to "".

description property ¤

description: str

Returns the description of the season

Returns:

  • str ( str ) –

    description of the season

details_url property writable ¤

details_url: str

Returns the details url of the season

Returns:

  • str ( str ) –

    details url of the season

episodes property ¤

episodes: List[Episode]

Returns the list of episodes in the season.

Returns:

  • List[Episode]

    List[Episode]: A list of Episode objects representing the episodes in the season.

note property writable ¤

note: str

Get the note of the show

This method returns the note of the show.

Returns:

  • str ( str ) –

    Note of the show

relative_season_dir property ¤

relative_season_dir: str

Returns the relative directory for the current season.

If the season index is 0, the relative specials directory is returned. Otherwise, the relative directory for the current season is returned.

Returns:

  • str ( str ) –

    The relative directory for the current season.

relative_specials_dir property ¤

relative_specials_dir: str

Returns the relative specials directory

This method returns the relative directory for the specials of the season.

Returns:

  • str ( str ) –

    relative specials directory

season_index property ¤

season_index: int

Returns the season index

This method returns the index of the season. If the index has not been set yet, it will be determined based on the title of the season. If the title does not contain a season index, the default index of 1 will be returned.

Returns:

  • int ( int ) –

    season index

show property ¤

show: Show

Returns the show of the season

Returns:

  • Show ( Show ) –

    show of the season

source property ¤

source: Source

Returns the source of the season

Returns:

  • Source ( Source ) –

    source of the season

title property ¤

title: str

Returns the title of the season

Returns:

  • str ( str ) –

    title of the season

year property ¤

year: str

Returns the year of the season

Returns:

  • str ( str ) –

    year of the season

create_show ¤

create_show() -> Show

Create a parent show for this season.

This method creates a parent show for the current season object. The parent show is created using the source type, title, and beginning year of the current season. The created show is then returned.

Returns:

  • Show ( Show ) –

    The created parent show.

determine_season_index ¤

determine_season_index(season_title: str) -> int

Determines season index from title of season

Parameters:

  • season_title (str) –

    Title of the season to query with. Defaults to None.

Returns:

  • int ( int ) –

    index of season

determine_show_begin_year ¤

determine_show_begin_year() -> str

Query the begin year of the show

This method determines the begin year of the show based on the season's year and index. If the season index is greater than 1, it prompts the user to input the year of the first season.

Returns:

  • str ( str ) –

    Begin year of the show as a string

fetch_details ¤

fetch_details() -> None

Fetch details for season for download.

This method creates a show, generates episodes, and fetches details for the season to prepare for download.

generate_episodes ¤

generate_episodes() -> None

Generate Episode objects for the season.

This method generates Episode objects for the season based on the list of episodes associated with the season. If an episode in the list is already an Episode object, it is added to the list of generated Episode objects. If an episode in the list is not an Episode object, its details are parsed from the source and a new Episode object is created and added to the list of generated Episode objects.

Returns:

  • None

    None

check_season_index ¤

check_season_index(show_title: str) -> int

Checks the season number for a particular show based on the show title.

Parameters:

  • show_title (str) –

    The title of the show to check.

Returns:

  • int ( int ) –

    The index of the season identified from the title.

show ¤

TYSD Show Class, parent of Seasons Currently not used a lot, will consider removing

Show ¤

Show(source: Source, title: str = '', begin_year: str = '')

Represents a TV show.

Attributes:

  • _title (str) –

    The title of the show.

  • _source (Source) –

    The source of the show.

  • _seasons (List[Season]) –

    The seasons of the show.

  • _begin_year (str) –

    The year the show began.

  • _prefix (str) –

    The directory name of the show.

Parameters:

  • source (Source) –

    The source of the show.

  • title (str, default: '' ) –

    The title of the show. Defaults to "".

  • begin_year (str, default: '' ) –

    The year the show began. Defaults to "".

begin_year property ¤

begin_year: str

Returns the begin year of the show

Returns:

  • str ( str ) –

    begin year of the show

relative_show_dir property ¤

relative_show_dir: str

Get the relative directory of the show in the media directory from the base path.

This method returns the relative directory of the show in the media directory from the base path.

Returns:

  • str ( str ) –

    The relative directory of the show in the media directory from the base path.

seasons property ¤

seasons: List[Season]

Returns a list of all the seasons of the show.

Returns:

  • List[Season]

    List[Season]: A list of all the seasons of the show.

show_prefix property ¤

show_prefix: str

Returns the show prefix, which is the directory name of the show.

If the show prefix has already been set, it will be returned. Otherwise, it will be generated using the generate_show_prefix method.

Returns:

  • str ( str ) –

    The show prefix (the directory name of the show).

source property ¤

source: str

Getter method for the source of the current Show.

Returns:

  • str ( str ) –

    The source of the current Show.

title property writable ¤

title: str

Get the title of the show

This method returns the title of the show.

Returns:

  • str ( str ) –

    Title of the show

generate_show_prefix ¤

generate_show_prefix() -> str

Generate the prefix for the show.

The prefix is the directory name of the show, and is generated by combining the show's title and beginning year.

Returns:

  • str ( str ) –

    The prefix for the show.