taegel.controllers package
Submodules
taegel.controllers.data module
- taegel.controllers.data.filter_arguments(url_list: list[str]) ArgsFiltered
Given an list of links, or random strings, it will return an object that separates the videos from the playlist in a way to select just the valid links or the ones that was not appended to the video or playlists lists.
Also, when any string has a valid playlist or video ID, it will get that ID to generate a valid link to work with. Witch means that Invidius, for example, URL’s will work just fine with that function.
- Parameters
url_list (List[str]) – Unordered list provided by the user.
- taegel.controllers.data.gen_album_list(videos: list[str], playlists: list[str], root_target: str, procs: int) list[taegel.models.types.AlbumInfo]
Return a list with a
AlbumInfo
object for each playlist. Thetarget
field for each of them will be thetarget
parameter plus the playlist name, or thetarget
itself for the videos only URL’s (they will be trated as a single playlist).- Parameters
videos (list[str]) – List with a bunch of links given by the user.
playlists (list[str]) – List with a bunch of playlist links.
root_target (str) – User’s target directory to download the files.
taegel.controllers.filesystem module
- taegel.controllers.filesystem.check_target_dir(target: str, display=True) None
Check if the target directory exists and create it if not. Also, it will complain if the target directory is not empty.
- Parameters
target (str) – Path to the directory to check/create
display (bool) – Display log messages when interating with the system
- taegel.controllers.filesystem.create_cache_dir() str
Create the taegel cache dir and return the name of that directory. Of course it isn’t cross plataform, which meas it work only on unix machines.
- taegel.controllers.filesystem.rename_song(target_file: Optional[str]) Optional[str]
Rename a mp4 song to an mp3 one, and return an info message if that file already exists.
- Parameters
terget_file (str) – Full path with the song name.
taegel.controllers.parallel module
- taegel.controllers.parallel.download_handler(album: AlbumInfo, procs: int, tasks: int, done=0) None
Main download handler that runs the multiprocessing stuff and the nice looking progress bar (
taegel.views.progress.downloading()
) at the same time in different process.They share information – such as some logging messages – through a pipe channel connected in these two proccesses.
- Parameters
down_data (DownloadData) – Information needed to execute the downloading process.
procs (int) – How many processes will be running to download the URL list in the
taegel.models.objects.DownloadData()
object.tasks (int) – How many tasks need to run.
done (int) – How many of them is already done.
- taegel.controllers.parallel.download_pool(cpipe: Connection, album: AlbumInfo, procs: int) None
Create a pool of processes and call the
taegel.controllers.youtube.download()
function using the URL list provide by thedown_data
parammeter. That function will be executed with every URL using multiple process at the same time.- Parameters
cpipe (multiprocessing.connection.Connection) – Parent pipe connection to pass to the download function, in order to make it send info through that pipe.
down_data (DownloadData) – Downlaod data with a list of URL’s to download.
parallel_procs (int) – Max procs that will be running in parallel.
taegel.controllers.youtube module
- taegel.controllers.youtube.download(cpipe: Connection, target: str, url: str) None
Download the YouTube video and save to the
target
directory. Sending some useful log information throught the parent pipe channel.Also, it just send an “task failed” log if the given link is brocken or the video is not valid, and terminate the function without errors.
- Parameters
cpipe (Connection) – Parent pipe to send the log messages.
target (str) – Target directory path.
url (str) – Video URL.
- taegel.controllers.youtube.playlist_to_album(url: str, target: str) AlbumInfo
Given a playlist link, it will create an
AlbumInfo
object with a list of the videos within that plylist. Thetarget
field will be appended with the playlist name.- Parameters
url (str) – Playlist URL.
target (str) – Target directory.
- taegel.controllers.youtube.youtube_api(url: str) tuple[Optional[pytube.__main__.YouTube], Optional[pytube.streams.Stream], Optional[str]]
Connect to the Youtube API to get the URL information (such as title, channel name, etc) and the video to download.
- Parameters
url (str) – Video URL to handle.