Skip to main content

A tool to download and merge M3U8 segments into an MP4 file.

Project description

m3loader

Overview

m3loader is a Python tool that downloads and merges M3U8 segments into a single MP4 file using asynchronous operations for fast downloads. It supports progress bars, retries, and unique segment directories for concurrent sessions.

Features

  • Asynchronous downloading of M3U8 segments
  • Merging segments into a single MP4 file
  • Support for progress bars and retries
  • Timeout support for downloads
  • Unique segment directories for concurrent sessions

Installation

You can install m3loader via pip:

pip install m3loader

Usage

Command Line Interface (CLI)

To use m3loader from the command line, you can use the following command:

m3loader <M3U8_URL> -d <OUTPUT_DIR> -o <OUTPUT_FILE> -p -t <TIMEOUT> -r <RETRIES>

Options

  • <M3U8_URL>: The URL of the M3U8 file.
  • -d <OUTPUT_DIR>: Output directory for the MP4 file. Default is the current directory.
  • -o <OUTPUT_FILE>: Output file name (with or without .mp4 extension). If not provided, a default name is used.
  • -p: Show progress bar and merging messages.
  • -t <TIMEOUT>: Set timeout for downloading in seconds.
  • -r <RETRIES>: Set maximum number of retries for downloading segments.

Example

m3loader "https://example.com/path/to/playlist.m3u8" -d workers -o video -p -t 300 -r 3

As a Function

You can also use m3loader as a function in your Python scripts. First, import the download function from the m3loader.dloader module:

from m3loader.dloader import download

m3u8_url = "https://example.com/path/to/playlist.m3u8"
output_path = "workers"
output_name = "video"
progress = True
timeout = 300
retries = 3

download(m3u8_url, output_path, output_name, progress, timeout, retries)

Function Parameters

  • m3u8_url (str): URL of the M3U8 file.
  • output_path (str): Output path for the MP4 file. Default is the current directory.
  • output_name (str): Output file name (with or without .mp4 extension). If not provided, a default name is used.
  • progress (bool): Show progress bar and merging messages. Default is False.
  • timeout (int): Set timeout for downloading in seconds. Default is None.
  • retries (int): Set maximum number of retries for downloading segments. Default is None.

Example Script

Here’s a complete example script using the m3loader function:

example_script.py

from m3loader.dloader import download

m3u8_url = "https://example.com/path/to/playlist.m3u8"
output_path = "workers"
output_name = "video"
progress = True
timeout = 300
retries = 3

download(m3u8_url, output_path, output_name, progress, timeout, retries)

Project Structure

The m3loader project has the following structure:

m3loader/
├── LICENSE
├── README.md
├── requirements.txt
├── setup.py
├── m3loader/
│   ├── __init__.py
│   ├── dloader.py
└── example/
    ├── sample.m3u8
    └── test_video.mp4

Contributing

If you would like to contribute to m3loader, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

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

m3loader-0.2.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

m3loader-0.2.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file m3loader-0.2.1.tar.gz.

File metadata

  • Download URL: m3loader-0.2.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.0

File hashes

Hashes for m3loader-0.2.1.tar.gz
Algorithm Hash digest
SHA256 aa2ab42d4dba3e71fec36af9d8b67edd178f8de983a67b5d816ed1b9f9d7d2f3
MD5 a51da0c2c59af4a6443adefc8ac34961
BLAKE2b-256 4fc0b7aec8d179060e2fd4080cee03a4b3b1f039d1bebe64a3e64834e59782da

See more details on using hashes here.

File details

Details for the file m3loader-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: m3loader-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.0

File hashes

Hashes for m3loader-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52207210ffe3e3de5561943c7bbe044dc19f23fa3be0537f30e6cd34433496d4
MD5 51a384cf7dffa5ff54a788e19a7f0538
BLAKE2b-256 cb942659a59600f7053e9528a95165b691b627b6cdd398eff76b254bb0536653

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