DDownloader 0.1.3__py3-none-any.whl → 0.1.5__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/__init__.py CHANGED
@@ -1,3 +1,11 @@
1
- from .hls_downloader import HLSDownloader
2
- from .dash_downloader import DASHDownloader
3
- from .decrypt_downloader import DecryptDownloader
1
+ from .bin import *
2
+ from .dash_downloader import DASH
3
+ from .hls_downloader import HLS
4
+ from .streamlink import STREAMLINK
5
+
6
+ __all__ = [
7
+ 'DDownloader',
8
+ 'HLS',
9
+ 'STREAMLINK',
10
+ 'DASH'
11
+ ]
@@ -1,44 +1,84 @@
1
- import requests
2
- import os
3
- import xml.etree.ElementTree as ET
4
- import subprocess
5
-
6
- class DASHDownloader:
7
- def __init__(self, manifest_url):
8
- self.manifest_url = manifest_url
9
- self.binary_path = os.path.join(os.path.dirname(__file__), 'bin', 'N_m3u8DL-RE')
10
-
11
- def download_with_n_m3u8dl(self):
12
- command = [self.binary_path, self.manifest_url]
13
- try:
14
- exit_code = subprocess.run(command, check=True)
15
- print("Downloaded using N_m3u8DL-RE")
16
- except subprocess.CalledProcessError as e:
17
- print(f"Error during download: {e}")
18
-
19
- def download_manifest(self):
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}")
1
+ import os
2
+ import subprocess
3
+ import logging
4
+ import platform # For platform detection
5
+ import coloredlogs
6
+ from colorama import Fore
7
+
8
+ # Set up logging
9
+ logger = logging.getLogger("+ DASH + ")
10
+ coloredlogs.install(level='DEBUG', logger=logger)
11
+
12
+ class DASH:
13
+ def __init__(self):
14
+ self.manifest_url = None
15
+ self.output_name = None
16
+ self.decryption_key = None # Default to None, making it optional
17
+ self.binary_path = self._get_binary_path()
18
+
19
+ def _get_binary_path(self):
20
+ """Determine the correct binary path based on the platform."""
21
+ base_path = os.path.join(os.path.dirname(__file__), 'bin', 'N_m3u8DL-RE')
22
+
23
+ if platform.system() == 'Windows':
24
+ binary = f"{base_path}.exe"
25
+ elif platform.system() == 'Linux':
26
+ binary = base_path # Linux binaries usually have no extension
27
+ elif platform.system() == 'Darwin': # macOS
28
+ binary = base_path # Adjust if necessary for macOS-specific binaries
29
+ else:
30
+ logger.error(f"Unsupported platform: {platform.system()}")
31
+ raise OSError(f"Unsupported platform: {platform.system()}")
32
+
33
+ if not os.path.exists(binary):
34
+ logger.error(f"Binary not found: {binary}")
35
+ raise FileNotFoundError(f"Binary not found: {binary}")
36
+
37
+ return binary
38
+
39
+ def dash_downloader(self):
40
+ if not self.manifest_url:
41
+ logger.error("Manifest URL is not set.")
42
+ return
43
+
44
+ command = self._build_command()
45
+
46
+ # logger.debug(f"Running command: {command}")
47
+ self._execute_command(command)
48
+
49
+ def _build_command(self):
50
+ # Build the basic command without extra quotes
51
+ command = [
52
+ self.binary_path, # Path to the binary
53
+ self.manifest_url, # The manifest URL
54
+ '--auto-select',
55
+ '-mt',
56
+ '--thread-count', '12',
57
+ '--save-dir', 'downloads',
58
+ '--tmp-dir', 'downloads',
59
+ '--save-name', self.output_name # The output name
60
+ ]
61
+
62
+ # Only add decryption_key if it's provided
63
+ if self.decryption_key:
64
+ logger.debug(f"Decryption key provided: {self.decryption_key}")
65
+ command.append(f'--key {self.decryption_key}') # Ensure correct format: KID:KEY
66
+
67
+ # Join the command as a single string for system execution
68
+ command_str = ' '.join(command)
69
+ # logger.debug(f"Command string: {command_str}")
70
+
71
+ return command_str
72
+
73
+ def _execute_command(self, command):
74
+ try:
75
+ # Use os.system to run the command as a string
76
+ result = os.system(command)
77
+
78
+ if result == 0:
79
+ logger.info("Downloaded using N_m3u8DL-RE successfully.")
80
+ else:
81
+ logger.error(f"Download failed with result code: {result}")
82
+
83
+ except Exception as e:
84
+ logger.error(f"An unexpected error occurred: {e}")
@@ -1,40 +1,83 @@
1
- import requests
2
- import os
3
- import subprocess
4
-
5
- class HLSDownloader:
6
- def __init__(self, manifest_url):
7
- self.manifest_url = manifest_url
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}")
17
-
18
- def download_manifest(self):
19
- response = requests.get(self.manifest_url)
20
- response.raise_for_status()
21
- return response.text
22
-
23
- def download_segments(self, manifest_content, output_dir='downloads'):
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)
30
-
31
- def download_segment(self, segment_url, output_dir):
32
- response = requests.get(segment_url, stream=True)
33
- response.raise_for_status()
34
-
35
- filename = os.path.join(output_dir, segment_url.split("/")[-1])
36
- with open(filename, 'wb') as f:
37
- for chunk in response.iter_content(chunk_size=8192):
38
- f.write(chunk)
39
-
40
- print(f"Downloaded: {filename}")
1
+ import os
2
+ import subprocess
3
+ import logging
4
+ import platform # For platform detection
5
+ import coloredlogs
6
+ from colorama import Fore
7
+
8
+ # Set up logging
9
+ logger = logging.getLogger(Fore.RED + "+ HLS + ")
10
+ coloredlogs.install(level='DEBUG', logger=logger)
11
+
12
+ class HLS:
13
+ def __init__(self):
14
+ self.manifest_url = None
15
+ self.output_name = None
16
+ self.decryption_key = None # Default to None, making it optional
17
+ self.binary_path = self._get_binary_path()
18
+
19
+ def _get_binary_path(self):
20
+ """Determine the correct binary path based on the platform."""
21
+ base_path = os.path.join(os.path.dirname(__file__), 'bin', 'N_m3u8DL-RE')
22
+
23
+ if platform.system() == 'Windows':
24
+ binary = f"{base_path}.exe"
25
+ elif platform.system() == 'Linux':
26
+ binary = base_path # Linux binaries usually have no extension
27
+ elif platform.system() == 'Darwin': # macOS
28
+ binary = base_path # Adjust if necessary for macOS-specific binaries
29
+ else:
30
+ logger.error(f"Unsupported platform: {platform.system()}")
31
+ raise OSError(f"Unsupported platform: {platform.system()}")
32
+
33
+ if not os.path.exists(binary):
34
+ logger.error(f"Binary not found: {binary}")
35
+ raise FileNotFoundError(f"Binary not found: {binary}")
36
+
37
+ return binary
38
+
39
+ def hls_downloader(self):
40
+ if not self.manifest_url:
41
+ logger.error("Manifest URL is not set.")
42
+ return
43
+
44
+ command = self._build_command()
45
+
46
+ # logger.debug(f"Running command: {command}")
47
+ self._execute_command(command)
48
+
49
+ def _build_command(self):
50
+ # Build the command to pass to os.system()
51
+ command = [
52
+ self.binary_path, # Path to the binary
53
+ self.manifest_url, # Manifest URL (no need for quotes)
54
+ '--auto-select',
55
+ '-mt',
56
+ '--thread-count', '12',
57
+ '--save-dir', 'downloads',
58
+ '--tmp-dir', 'downloads',
59
+ '--save-name', self.output_name # The output name (no quotes)
60
+ ]
61
+
62
+ # Only add decryption_key if it's provided
63
+ if self.decryption_key:
64
+ command.append(f'--key {self.decryption_key}') # Ensure correct format: KID:KEY
65
+
66
+ # Join the command as a single string for system execution
67
+ command_str = ' '.join(command)
68
+ # logger.debug(f"Command string: {command_str}")
69
+
70
+ return command_str
71
+
72
+ def _execute_command(self, command):
73
+ try:
74
+ # Use os.system to run the command as a string
75
+ result = os.system(command)
76
+
77
+ if result == 0:
78
+ logger.info("Downloaded using N_m3u8DL-RE successfully.")
79
+ else:
80
+ logger.error(f"Download failed with result code: {result}")
81
+
82
+ except Exception as e:
83
+ logger.error(f"An unexpected error occurred: {e}")
@@ -0,0 +1,19 @@
1
+ import os
2
+ import subprocess
3
+ import logging
4
+ import coloredlogs
5
+ from colorama import Fore
6
+
7
+ # Set up logging
8
+ logger = logging.getLogger(Fore.RED + " + STREAMLINK + ")
9
+ coloredlogs.install(level='DEBUG', logger=logger)
10
+
11
+ class STREAMLINK:
12
+ def __init__(self):
13
+ self.url = None
14
+ self.output_name = None
15
+ self.live_url = None
16
+ self.binary_path = os.path.join(os.path.dirname(__file__), 'bin', 'streamlink')
17
+
18
+ def streamlink_restream(self):
19
+ pass
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.1
2
+ Name: DDownloader
3
+ Version: 0.1.5
4
+ Summary: A downloader for DRM-protected content.
5
+ Home-page: https://github.com/ThatNotEasy/DDownloader
6
+ Author: ThatNotEasy
7
+ Author-email: apidotmy@proton.me
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: requests
15
+ Requires-Dist: coloredlogs
16
+ Requires-Dist: loguru
17
+ Requires-Dist: argparse
18
+
19
+ # DDownloader
20
+ - DDownloader is a Python library to download HLS and DASH manifests and decrypt media files.
21
+
22
+ # Features
23
+ - Download HLS streams using N_m3u8DL-RE.
24
+ - Download DASH manifests and segments.
25
+ - Decrypt media files using mp4decrypt.
26
+
27
+ # Installation
28
+ Use the package manager pip to install DDownloader.
29
+ ```pip install DDownloader==0.1.4```
30
+
31
+ # Usage
32
+
33
+ - Download DASH content using the library:
34
+
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()
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
+ # THIS PROJECT STILL IN DEVELOPMENT
@@ -0,0 +1,9 @@
1
+ DDownloader/__init__.py,sha256=2qcq67r0hzIQ5dYnX5c8da19aPqSYutZmwwIFdsW1JU,203
2
+ DDownloader/dash_downloader.py,sha256=8iyOwbZIoEM-AM50UX2-jBjgHjbUvBHzemVLUDe4C74,3120
3
+ DDownloader/hls_downloader.py,sha256=kOb4zh5-M6-N9zs63NCmpKoQrxjswCDAj1woH9-0TZo,3053
4
+ DDownloader/streamlink.py,sha256=F8vneSkxgGgqxRBhCHxvID-KwltpDG2QerH6QsAHuxE,506
5
+ DDownloader-0.1.5.dist-info/METADATA,sha256=S4_sHj06Fso-MLDIpbTrukbwV0S2QHhqcixueAP3lBk,1836
6
+ DDownloader-0.1.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
7
+ DDownloader-0.1.5.dist-info/entry_points.txt,sha256=1jTwDiTcHyA4otMMuIpIDnHclZ6k23GbIfKgp1zTGYw,54
8
+ DDownloader-0.1.5.dist-info/top_level.txt,sha256=INZYgY1vEHV1MIWTPXKJL8j8-ZXjWb8u4XLuU3S8umY,12
9
+ DDownloader-0.1.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.2.0)
2
+ Generator: bdist_wheel (0.45.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ddownloader = ddownloader.main:main
@@ -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,,