A simple downloader videos from maktabkhooneh
Project description
maktab-dl
A command-line tool to download videos from Maktabkhooneh courses.
Installation
-
Install using pip
pip install maktab-dl
-
Clone the Repository (Optional):
If you have access to the repository, you can clone it:
> git clone https://github.com/softrebel/maktab-dl.git > cd maktab-dl > pip install .
Usage
The maktab-dl tool provides a download subcommand for downloading course videos.
maktab-dl download [options]
Command
download: This subcommand is used to download course videos.
Options
The download subcommand accepts the following options:
-u,--url(Required): The URL of the Maktabkhooneh course page.-c,--cookies(Optional): The path to the cookies file. Defaults to acookies.jsonfile in a suitable user data directory as specified byappdirspackage.-o,--output(Optional): The path to the output directory where videos will be saved. Defaults to the current directory the script is called from.
Examples
Here are some examples of how to use maktab-dl:
-
Basic Download with Default Options:
If you have saved cookies, it will automatically use it to download the course video. This will save the course in the current directory
maktab-dl download -u <your_course_url>
for example:
maktab-dl download -u https://maktabkhooneh.org/course/آموزش-سی-شارپ-c-mk9558/
-
Download with custom cookies and output directories:
maktab-dl download -u <your_course_url> -c /path/to/my/cookies.json -o /path/to/my/output
-
First time login and save cookies:
If you run this command and cookies file does not exist in the defined path, it will ask username, password, and confirmation to save cookies.
maktab-dl download -u <your_course_url> -c /path/to/my/cookies.json
-
When cookies is not valid:
If you run the script with invalid cookie file, it will ask you to login again
maktab-dl download -u <your_course_url> -c /path/to/my/invalid_cookie.json
-
Using relative path for cookies
maktab-dl download -u <your_course_url> -c ./my_cookies.json -o ./videos
This command will save the cookies in current directory and video in the videos subdirectory.
-
Help Message:
To see the available options and usage information, run:
maktab-dl download --help
or
maktab-dl --help
Explanation
First time Login
- If you run the script with a cookies file path that does not exist, it will prompt you for your Maktabkhooneh username and password.
- After logging in successfully, it will ask you if you would like to save the cookies to the specified path.
- Subsequent executions can reuse the saved cookie to make the script work seamlessly.
- If cookies are present but not valid it will ask you to relogin.
Default Paths
- Cookies File: If you don't provide the path to the cookies file, it will save
cookies.jsonto suitable user data directory. The exact location will depend on your operating system (Linux, macOS, or Windows). The location is handled byappdirspackage. - Output Directory: If you don't specify the output directory, it will save the video in the current directory the command was run from.
Error Handling
- The script includes basic error handling to catch exceptions that might happen during the downloading process. The error is printed to console with descriptive message.
- You will be informed if cookies file can not be found or invalid.
- If the course does not have any video, it will log the message into console.
Dependencies
httpx: Used for making HTTP requests.lxml: Used for parsing HTML content.appdirs: Used for finding user specific os paths.
Important Notes
- This script requires a Maktabkhooneh account to download courses.
- The script will create output directory automatically when you are saving videos there.
This documentation should provide a good starting point for users of your maktab-dl package. Let me know if you have any other questions!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maktab_dl-0.4.0.tar.gz.
File metadata
- Download URL: maktab_dl-0.4.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7572f07982b8b34dcad767a855009922f4630705560f18f871e6ea93c6196402
|
|
| MD5 |
e5515fe1b6f267362affba19663c73c4
|
|
| BLAKE2b-256 |
8f0d4f955530398a3fa67615926e2673178892acaba1cfc8dfbdfce55c9c2092
|
File details
Details for the file maktab_dl-0.4.0-py3-none-any.whl.
File metadata
- Download URL: maktab_dl-0.4.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.25
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3e798382ab8a51c81e83d13ab16d441f24e1ebe9de2a45af0255ed362152465
|
|
| MD5 |
fad0130184bd09ec4302636f51384fc0
|
|
| BLAKE2b-256 |
830adc3aa837ef6d603d1955145f65cb043a5841583c611fe8c2bc39448a262e
|