Skip to main content

A multithreading m3u8 download module for python, and the number of threads can decide by yourself; Convert .m3u8 file to .mp4 file; Supporting redownload.

Project description

M3u8 Downloader

A multithread m3u8 download module and the number of threads can decide by yourself. using how many threads is decide by your network and your device.

Github : https://github.com/walkureHHH/M3u8-Downloader/

1. Install

pip install mder

2. Import

import mder

3. Instance object and start download

downloader = mder.m3u8_downloader(m3u8_file_path='./test.m3u8',temp_file_path='./',mp4_path='./test.mp4',num_of_threads=10)
# parameters
# 1.m3u8_file_path
# default : no default   (type : str)
# 2.temp_file_path
# default : '.'          (type : str)
# 3.mp4_path
# default : './test.mp4' (type : str)
# 4.num_of_threads
# default : 10           (type : int)

downloader.start()
# parameters
# 1.mod
# default : 0            (type : int)
# mod 0 means delete TS folder and m3u8 file if download completely
# mod 1 means delete m3u8 file only if download completely
# mod 2 means delete TS folder only if download completely
# mod 3 means reserve TS folder and m3u8 file if download completely
# 2.time_out
# default : 60           (type : int)(units : seconds)
# The time_out is the timeout in request.get(timeout=)

before download

the structure of ./ is:

.
├── test.m3u8
└── test.py

when it is downloading

the structure of ./ is:

.
├── TS
│   ├── qzCFnDUZE9_720_5308_0000.ts
│   ├── qzCFnDUZE9_720_5308_0001.ts
│   ├── qzCFnDUZE9_720_5308_0002.ts
│   ├── qzCFnDUZE9_720_5308_0003.ts
│   ├── qzCFnDUZE9_720_5308_0004.ts
│   ├── qzCFnDUZE9_720_5308_0005.ts
│   ├── qzCFnDUZE9_720_5308_0006.ts
│   ├── qzCFnDUZE9_720_5308_0007.ts
│   ├── qzCFnDUZE9_720_5308_0008.ts
│   ├── qzCFnDUZE9_720_5308_0009.ts
│   └── qzCFnDUZE9_720_5308_0010.ts  
├── test.m3u8
└── test.py

process bar: <<*>> 29% 500/1752 [01:33<04:02] <<*>>

TS is temp folder, all .ts file are in it. The path of it is %temp_file_path%/TS, in the test case, it is in ./TS. If the mission is not complete, the m3u8 file and TS folder will be reserved, you can instance a new downloader with corresponding TS folder and m3u8 file, and use the start() function to begin, in this way, the mission will go on.

after download and download successfully

the structure of ./ is:

.
├── test.mp4
└── test.py

If some .ts download failed, the module will redownload for 4 times, and the information will print to the command line

at last, the command line is like this:

<<*>>  99% 1737/1752 [05:35<00:22] <<*>>
thread0 Time out ERROR qzCFnDUZE9_720_5308_1710.ts
thread2 Time out ERROR qzCFnDUZE9_720_5308_1722.ts
thread0 redownload successfully qzCFnDUZE9_720_5308_1710.ts
<<*>>  99% 1738/1752 [06:20<03:19] <<*>>
thread2 redownload successfully qzCFnDUZE9_720_5308_1722.ts
<<*>> 100% 1752/1752 [06:26<00:00] <<*>>
downloading finished 100.00%

if complete

The attribute if_complete of class M3u8_Download can used to find if the download is conplete. In this example, we can use

a = downloader.if_complete # a == False means the downloading is incomplete.

5. restart

If you want to restart a incomplete mission, you only should use the corresponding TS folder and .m3u8 file.

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

mder-1.0.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

mder-1.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file mder-1.0.2.tar.gz.

File metadata

  • Download URL: mder-1.0.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for mder-1.0.2.tar.gz
Algorithm Hash digest
SHA256 db63c78555d29e9f49d7296572a1bd8055ed613186c8fddb9a7e9749d7d36b54
MD5 3f80c4b94a54d3a183de076f7c20614f
BLAKE2b-256 d25d1a9bdf99c1716f62d512d5d308510dcf9a7b50707233460504c974533c2c

See more details on using hashes here.

File details

Details for the file mder-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: mder-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for mder-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a2ca02b4c35158ab5587d8a2ce7f561c41efc168363ce04b7b4201747214fd0
MD5 5ded818dc2af8b8d248187ee43b4075c
BLAKE2b-256 a7c2bd96c0a6e828b1bc66add959688db435b6dc2763ee02f3fb997f9c3672a0

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