Skip to main content

A simple downloader videos from maktabkhooneh

Project description

maktab-dl

maktabkhooneh downloader A command-line tool to download videos from Maktabkhooneh courses.

Installation

  1. Install using pip

    pip install maktab-dl
    
  2. 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 a cookies.json file in a suitable user data directory as specified by appdirs package.
  • -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:

  1. 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/
    
  2. 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
    
  3. 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
    
  4. 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
    
  5. 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.

  6. 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.json to suitable user data directory. The exact location will depend on your operating system (Linux, macOS, or Windows). The location is handled by appdirs package.
  • 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.
  • pydantic: Used for validating response params.
  • tqdm: Used for display download progress bar in output.
  • lxml: Used for parsing HTML content.

Important Notes

  • This script requires a Maktabkhooneh account and access to specific course to download it.
  • The script will create output directory automatically when you are saving videos there.

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

maktab_dl-0.6.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maktab_dl-0.6.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file maktab_dl-0.6.0.tar.gz.

File metadata

  • Download URL: maktab_dl-0.6.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.25

File hashes

Hashes for maktab_dl-0.6.0.tar.gz
Algorithm Hash digest
SHA256 2e139d58bcb58f28dd21e7627a3dddb24ab4cb7019e05245dfe7104f618aa22b
MD5 60c70fdc824a9fb633b89fdfb0594568
BLAKE2b-256 01f094d351b662b46a0acef4b6c28ea1e7a8cf6007e53e3786cd17d42be697a8

See more details on using hashes here.

File details

Details for the file maktab_dl-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: maktab_dl-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.25

File hashes

Hashes for maktab_dl-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d604e09325ccec9b8c542b5694fcecb2fb083e015b63ef0efc38742d2f44ac45
MD5 7f9b39a1fe617fd8fe24c381fd0e3762
BLAKE2b-256 439e9195dbd5a16a77fd759443ee07f37eb6aa8864837797c087b9303bedacef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page