DDownloader 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DDownloader/bin/N_m3u8DL-RE +0 -0
- DDownloader/bin/N_m3u8DL-RE.exe +0 -0
- DDownloader/bin/packager-linux-x64 +0 -0
- DDownloader/bin/packager-win-x64.exe +0 -0
- DDownloader/dash_downloader.py +43 -38
- DDownloader/hls_downloader.py +42 -33
- DDownloader-0.1.4.dist-info/METADATA +80 -0
- DDownloader-0.1.4.dist-info/RECORD +11 -0
- DDownloader/decrypt_downloader.py +0 -39
- DDownloader-0.1.3.dist-info/METADATA +0 -77
- DDownloader-0.1.3.dist-info/RECORD +0 -8
- {DDownloader-0.1.3.dist-info → DDownloader-0.1.4.dist-info}/WHEEL +0 -0
- {DDownloader-0.1.3.dist-info → DDownloader-0.1.4.dist-info}/top_level.txt +0 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
DDownloader/dash_downloader.py
CHANGED
@@ -1,44 +1,49 @@
|
|
1
|
-
import requests
|
2
1
|
import os
|
3
|
-
import xml.etree.ElementTree as ET
|
4
2
|
import subprocess
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
import logging
|
4
|
+
import coloredlogs
|
5
|
+
|
6
|
+
# Set up logging
|
7
|
+
logger = logging.getLogger(__name__)
|
8
|
+
coloredlogs.install(level='DEBUG', logger=logger)
|
9
|
+
|
10
|
+
class DASH:
|
11
|
+
def __init__(self):
|
12
|
+
self.manifest_url = None
|
13
|
+
self.output_name = None
|
14
|
+
self.decryption_key = None
|
9
15
|
self.binary_path = os.path.join(os.path.dirname(__file__), 'bin', 'N_m3u8DL-RE')
|
10
16
|
|
11
|
-
def
|
12
|
-
|
17
|
+
def dash_downloader(self):
|
18
|
+
if not self.manifest_url:
|
19
|
+
logger.error("Manifest URL is not set.")
|
20
|
+
return
|
21
|
+
|
22
|
+
command = self._build_command()
|
23
|
+
|
24
|
+
logger.debug(f"Running command: {' '.join(command)}")
|
25
|
+
self._execute_command(command)
|
26
|
+
|
27
|
+
def _build_command(self):
|
28
|
+
command = [
|
29
|
+
self.binary_path,
|
30
|
+
self.manifest_url,
|
31
|
+
'--auto-select',
|
32
|
+
'-mt',
|
33
|
+
'--thread-count', '12',
|
34
|
+
'--save-dir', 'downloads',
|
35
|
+
'--tmp-dir', 'downloads',
|
36
|
+
'--save-name', self.output_name
|
37
|
+
]
|
38
|
+
if self.decryption_key:
|
39
|
+
command.append(f'--key {self.decryption_key}')
|
40
|
+
return command
|
41
|
+
|
42
|
+
def _execute_command(self, command):
|
13
43
|
try:
|
14
|
-
|
15
|
-
|
44
|
+
subprocess.run(command, check=True)
|
45
|
+
logger.info("Downloaded using N_m3u8DL-RE")
|
16
46
|
except subprocess.CalledProcessError as e:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
response = requests.get(self.manifest_url)
|
21
|
-
response.raise_for_status()
|
22
|
-
return response.content
|
23
|
-
|
24
|
-
def download_segments(self, manifest_content, output_dir='downloads'):
|
25
|
-
os.makedirs(output_dir, exist_ok=True)
|
26
|
-
root = ET.fromstring(manifest_content)
|
27
|
-
|
28
|
-
for adaptation_set in root.findall('.//AdaptationSet'):
|
29
|
-
for representation in adaptation_set.findall('Representation'):
|
30
|
-
base_url = representation.attrib.get('baseURL', '')
|
31
|
-
for segment in representation.findall('.//SegmentURL'):
|
32
|
-
segment_url = base_url + segment.attrib['media']
|
33
|
-
self.download_segment(segment_url, output_dir)
|
34
|
-
|
35
|
-
def download_segment(self, segment_url, output_dir):
|
36
|
-
response = requests.get(segment_url, stream=True)
|
37
|
-
response.raise_for_status()
|
38
|
-
|
39
|
-
filename = os.path.join(output_dir, segment_url.split("/")[-1])
|
40
|
-
with open(filename, 'wb') as f:
|
41
|
-
for chunk in response.iter_content(chunk_size=8192):
|
42
|
-
f.write(chunk)
|
43
|
-
|
44
|
-
print(f"Downloaded: {filename}")
|
47
|
+
logger.error(f"Error during download: {e}")
|
48
|
+
except FileNotFoundError:
|
49
|
+
logger.error(f"Binary not found at: {self.binary_path}")
|
DDownloader/hls_downloader.py
CHANGED
@@ -1,40 +1,49 @@
|
|
1
|
-
import requests
|
2
1
|
import os
|
3
2
|
import subprocess
|
3
|
+
import logging
|
4
|
+
import coloredlogs
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
self.binary_path = os.path.join(os.path.dirname(__file__), 'bin', 'N_m3u8DL-RE')
|
9
|
-
|
10
|
-
def download_with_n_m3u8dl(self):
|
11
|
-
command = [self.binary_path, self.manifest_url]
|
12
|
-
try:
|
13
|
-
exit_code = subprocess.run(command, check=True)
|
14
|
-
print("Downloaded using N_m3u8DL-RE")
|
15
|
-
except subprocess.CalledProcessError as e:
|
16
|
-
print(f"Error during download: {e}")
|
6
|
+
# Set up logging
|
7
|
+
logger = logging.getLogger(__name__)
|
8
|
+
coloredlogs.install(level='DEBUG', logger=logger)
|
17
9
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
os.makedirs(output_dir, exist_ok=True)
|
25
|
-
lines = manifest_content.splitlines()
|
26
|
-
for line in lines:
|
27
|
-
if line.endswith('.ts'):
|
28
|
-
segment_url = line
|
29
|
-
self.download_segment(segment_url, output_dir)
|
10
|
+
class HLS:
|
11
|
+
def __init__(self):
|
12
|
+
self.manifest_url = None
|
13
|
+
self.output_name = None
|
14
|
+
self.decryption_key = None
|
15
|
+
self.binary_path = os.path.join(os.path.dirname(__file__), 'bin', 'N_m3u8DL-RE')
|
30
16
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
17
|
+
def hls_downloader(self):
|
18
|
+
if not self.manifest_url:
|
19
|
+
logger.error("Manifest URL is not set.")
|
20
|
+
return
|
21
|
+
|
22
|
+
command = self._build_command()
|
23
|
+
|
24
|
+
logger.debug(f"Running command: {' '.join(command)}")
|
25
|
+
self._execute_command(command)
|
34
26
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
def _build_command(self):
|
28
|
+
command = [
|
29
|
+
self.binary_path,
|
30
|
+
self.manifest_url,
|
31
|
+
'--auto-select',
|
32
|
+
'-mt',
|
33
|
+
'--thread-count', '12',
|
34
|
+
'--save-dir', 'downloads',
|
35
|
+
'--tmp-dir', 'downloads',
|
36
|
+
'--save-name', self.output_name
|
37
|
+
]
|
38
|
+
if self.decryption_key:
|
39
|
+
command.append(f'--key {self.decryption_key}')
|
40
|
+
return command
|
39
41
|
|
40
|
-
|
42
|
+
def _execute_command(self, command):
|
43
|
+
try:
|
44
|
+
subprocess.run(command, check=True)
|
45
|
+
logger.info("Downloaded using N_m3u8DL-RE")
|
46
|
+
except subprocess.CalledProcessError as e:
|
47
|
+
logger.error(f"Error during download: {e}")
|
48
|
+
except FileNotFoundError:
|
49
|
+
logger.error(f"Binary not found at: {self.binary_path}")
|
@@ -0,0 +1,80 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: DDownloader
|
3
|
+
Version: 0.1.4
|
4
|
+
Summary: A library to download HLS and DASH manifests and decrypt media files.
|
5
|
+
Author: Pari Malam
|
6
|
+
Author-email: shafiqsamsuri@serasi.tech
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
9
|
+
Classifier: Operating System :: OS Independent
|
10
|
+
Requires-Python: >=3.9
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
Requires-Dist: requests
|
13
|
+
Requires-Dist: coloredlogs
|
14
|
+
|
15
|
+
# DDownloader
|
16
|
+
|
17
|
+
**DDownloader** is a Python library to download HLS and DASH manifests and decrypt media files.
|
18
|
+
|
19
|
+
## Features
|
20
|
+
- Download HLS streams using `N_m3u8DL-RE`.
|
21
|
+
- Download DASH manifests and segments.
|
22
|
+
- Decrypt media files using `mp4decrypt`.
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
Use the package manager [pip](https://pypi.org/project/DDownloader/0.1.4/) to install DDownloader.
|
27
|
+
|
28
|
+
```bash
|
29
|
+
pip install DDownloader==0.1.4
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
- Download DASH content using the library:
|
35
|
+
```python
|
36
|
+
from DDownloader.dash_downloader import DASH
|
37
|
+
|
38
|
+
dash_downloader = DASH()
|
39
|
+
dash_downloader.manifest_url = "https://example.com/path/to/manifest.mpd" # Set your DASH manifest URL
|
40
|
+
dash_downloader.output_name = "output.mp4" # Set desired output name
|
41
|
+
dash_downloader.decryption_key = "12345:678910" # Set decryption key if needed
|
42
|
+
dash_downloader.dash_downloader() # Call the downloader method
|
43
|
+
```
|
44
|
+
|
45
|
+
- Download HLS content using the library:
|
46
|
+
```python
|
47
|
+
from DDownloader.hls_downloader import HLS
|
48
|
+
|
49
|
+
hls_downloader = HLS()
|
50
|
+
hls_downloader.manifest_url = "https://example.com/path/to/manifest.m3u8" # Set your HLS manifest URL
|
51
|
+
hls_downloader.output_name = "output.mp4" # Set desired output name
|
52
|
+
hls_downloader.decryption_key = "12345:678910" # Set decryption key if needed
|
53
|
+
hls_downloader.hls_downloader() # Call the downloader method
|
54
|
+
```
|
55
|
+
|
56
|
+
- Here's a complete example demonstrating the use of all features:
|
57
|
+
```python
|
58
|
+
from DDownloader.dash_downloader import DASH
|
59
|
+
from DDownloader.hls_downloader import HLS
|
60
|
+
|
61
|
+
def download_dash():
|
62
|
+
dash_downloader = DASH()
|
63
|
+
dash_downloader.manifest_url = "https://example.com/path/to/manifest.mpd" # Set your DASH manifest URL
|
64
|
+
dash_downloader.output_name = "output.mp4" # Set desired output name
|
65
|
+
dash_downloader.decryption_key = "12345:678910" # Set decryption key if needed
|
66
|
+
dash_downloader.dash_downloader() # Call the downloader method
|
67
|
+
|
68
|
+
def download_hls():
|
69
|
+
hls_downloader = HLS()
|
70
|
+
hls_downloader.manifest_url = "https://example.com/path/to/manifest.m3u8" # Set your HLS manifest URL
|
71
|
+
hls_downloader.output_name = "output_hls" # Set desired output name
|
72
|
+
hls_downloader.decryption_key = "your_decryption_key" # Set decryption key if needed
|
73
|
+
hls_downloader.hls_downloader() # Call the downloader method
|
74
|
+
|
75
|
+
if __name__ == "__main__":
|
76
|
+
download_dash() # Download DASH content
|
77
|
+
download_hls() # Download HLS content
|
78
|
+
```
|
79
|
+
|
80
|
+
## THIS PROJECT STILL IN DEVELOPMENT
|
@@ -0,0 +1,11 @@
|
|
1
|
+
DDownloader/__init__.py,sha256=o3loo1Z5ZdvQYZIjgdgZarMVMIz5pHRRZ_x0IXYA6nU,135
|
2
|
+
DDownloader/dash_downloader.py,sha256=Oe-IxT30xP71kOskVrzEkuvYOWRSxoDS3Jxh42MW9fk,1499
|
3
|
+
DDownloader/hls_downloader.py,sha256=cvKgs1AVWpqZmD6niYI2KYWnblowayxRCFBwPEU2FOM,1497
|
4
|
+
DDownloader/bin/N_m3u8DL-RE,sha256=y2vtfXq5RXYbyN-BV2QFc_jwZyZIUMKdnQMagkkaHwU,7498940
|
5
|
+
DDownloader/bin/N_m3u8DL-RE.exe,sha256=AmuDJQmtIeMSfpcVLt1Hqf5CCtSgxiQ_8KYgiYSeGbk,6456320
|
6
|
+
DDownloader/bin/packager-linux-x64,sha256=Ba8unvXxLVi51hW30x3A62HDKu5jLHGWU0C0PBVWBD4,9243968
|
7
|
+
DDownloader/bin/packager-win-x64.exe,sha256=LlRGcuMNHTvmwv3fZ-7b3m46iLYjHVfCrSfOQ-zpyTk,5279744
|
8
|
+
DDownloader-0.1.4.dist-info/METADATA,sha256=u0fV_84QXLpjmnremapTlI7xhJlYnqUWoSBvlbz8Ce4,2853
|
9
|
+
DDownloader-0.1.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
10
|
+
DDownloader-0.1.4.dist-info/top_level.txt,sha256=INZYgY1vEHV1MIWTPXKJL8j8-ZXjWb8u4XLuU3S8umY,12
|
11
|
+
DDownloader-0.1.4.dist-info/RECORD,,
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import subprocess
|
3
|
-
|
4
|
-
class DecryptDownloader:
|
5
|
-
def __init__(self):
|
6
|
-
self.kid = None
|
7
|
-
self.key = None
|
8
|
-
self.manifest_url = None
|
9
|
-
self.binary_path = os.path.join(os.path.dirname(__file__), 'bin', 'mp4decrypt') # Adjust if necessary
|
10
|
-
|
11
|
-
def set_manifest_url(self, manifest_url):
|
12
|
-
self.manifest_url = manifest_url
|
13
|
-
|
14
|
-
def set_decryption_key(self, key):
|
15
|
-
self.key = key
|
16
|
-
|
17
|
-
def set_kid(self, kid):
|
18
|
-
self.kid = kid
|
19
|
-
|
20
|
-
def download_and_decrypt(self, input_file, output_file):
|
21
|
-
if not self.key:
|
22
|
-
print("Decryption key is not set.")
|
23
|
-
return
|
24
|
-
|
25
|
-
self.download_media_file() # Placeholder for your download logic
|
26
|
-
|
27
|
-
command = [self.binary_path, '--key', f'{self.kid}:{self.key}', input_file, output_file]
|
28
|
-
try:
|
29
|
-
exit_code = subprocess.run(command, check=True)
|
30
|
-
print(f"Decrypted file saved as: {output_file}")
|
31
|
-
except subprocess.CalledProcessError as e:
|
32
|
-
print(f"Error during decryption: {e}")
|
33
|
-
|
34
|
-
def download_media_file(self):
|
35
|
-
if not self.manifest_url:
|
36
|
-
print("Manifest URL is not set.")
|
37
|
-
return
|
38
|
-
|
39
|
-
print(f"Downloading media from: {self.manifest_url}")
|
@@ -1,77 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: DDownloader
|
3
|
-
Version: 0.1.3
|
4
|
-
Summary: A library to download HLS and DASH manifests and decrypt media files.
|
5
|
-
Author: Pari Malam
|
6
|
-
Author-email: shafiqsamsuri@serasi.tech
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
9
|
-
Classifier: Operating System :: OS Independent
|
10
|
-
Requires-Python: >=3.9
|
11
|
-
Description-Content-Type: text/markdown
|
12
|
-
Requires-Dist: requests
|
13
|
-
|
14
|
-
# DDownloader
|
15
|
-
|
16
|
-
**DDownloader** is a Python library to download HLS and DASH manifests and decrypt media files.
|
17
|
-
|
18
|
-
## Features
|
19
|
-
- Download HLS streams using `N_m3u8DL-RE`.
|
20
|
-
- Download DASH manifests and segments.
|
21
|
-
- Decrypt media files using `mp4decrypt`.
|
22
|
-
|
23
|
-
## Installation
|
24
|
-
|
25
|
-
Use the package manager [pip](https://pypi.org/project/DDownloader/0.1.3/) to install DDownloader.
|
26
|
-
|
27
|
-
```bash
|
28
|
-
pip install DDownloader==0.1.3
|
29
|
-
```
|
30
|
-
|
31
|
-
## Usage
|
32
|
-
- Download HLS content using the library:
|
33
|
-
```python
|
34
|
-
from DDownloader import HLSDownloader
|
35
|
-
|
36
|
-
hls_downloader = HLSDownloader("https://example.com/playlist.m3u8")
|
37
|
-
hls_downloader.download_with_n_m3u8dl()
|
38
|
-
```
|
39
|
-
- Download Dash content using the library:
|
40
|
-
```python
|
41
|
-
from DDownloader import DASHDownloader
|
42
|
-
|
43
|
-
dash_downloader = DASHDownloader("https://example.com/manifest.mpd")
|
44
|
-
dash_downloader.download_with_n_m3u8dl()
|
45
|
-
```
|
46
|
-
- To decrypt media files after downloading:
|
47
|
-
```python
|
48
|
-
from DDownloader import DecryptDownloader
|
49
|
-
|
50
|
-
decrypt_downloader = DecryptDownloader()
|
51
|
-
decrypt_downloader.set_manifest_url("https://example.com/manifest.mpd")
|
52
|
-
decrypt_downloader.set_decryption_key("0123456789abcdef0123456789abcdef")
|
53
|
-
decrypt_downloader.set_kid("1:0123456789abcdef0123456789abcdef")
|
54
|
-
decrypt_downloader.download_and_decrypt("encrypted_file.mp4", "decrypted_file.mp4")
|
55
|
-
```
|
56
|
-
- Here's a complete example demonstrating the use of all features:
|
57
|
-
```python
|
58
|
-
from DDownloader import HLSDownloader, DASHDownloader, DecryptDownloader
|
59
|
-
|
60
|
-
# HLS Download Example
|
61
|
-
hls_url = "https://example.com/playlist.m3u8"
|
62
|
-
hls_downloader = HLSDownloader(hls_url)
|
63
|
-
hls_downloader.download_with_n_m3u8dl()
|
64
|
-
|
65
|
-
# DASH Download Example
|
66
|
-
dash_url = "https://example.com/manifest.mpd"
|
67
|
-
dash_downloader = DASHDownloader(dash_url)
|
68
|
-
dash_downloader.download_with_n_m3u8dl()
|
69
|
-
|
70
|
-
# Decrypting Example
|
71
|
-
decrypt_downloader = DecryptDownloader()
|
72
|
-
decrypt_downloader.set_manifest_url(dash_url)
|
73
|
-
decrypt_downloader.set_decryption_key("0123456789abcdef0123456789abcdef")
|
74
|
-
decrypt_downloader.set_kid("1:0123456789abcdef0123456789abcdef")
|
75
|
-
decrypt_downloader.download_and_decrypt("encrypted_file.mp4", "decrypted_file.mp4")
|
76
|
-
|
77
|
-
```
|
@@ -1,8 +0,0 @@
|
|
1
|
-
DDownloader/__init__.py,sha256=o3loo1Z5ZdvQYZIjgdgZarMVMIz5pHRRZ_x0IXYA6nU,135
|
2
|
-
DDownloader/dash_downloader.py,sha256=MTaM_8lmLJ9nFQKY-Q_akr9qsT88nlCy1bODCBV1Io8,1730
|
3
|
-
DDownloader/decrypt_downloader.py,sha256=LdjZkVgyPile6TRueFMNcRdZkkNVwoTL5qNp5i0De_c,1233
|
4
|
-
DDownloader/hls_downloader.py,sha256=OiTw2xdva5eM1QaxKgcRCpvkMaBpdjQrwtYtwvLZm4g,1435
|
5
|
-
DDownloader-0.1.3.dist-info/METADATA,sha256=hqx_gFsxL7XE_fD9Of1mp5IAre54ioOZvYaMHO35IbU,2487
|
6
|
-
DDownloader-0.1.3.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
7
|
-
DDownloader-0.1.3.dist-info/top_level.txt,sha256=INZYgY1vEHV1MIWTPXKJL8j8-ZXjWb8u4XLuU3S8umY,12
|
8
|
-
DDownloader-0.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|