DDownloader 0.3.3__tar.gz → 0.3.4__tar.gz

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.
@@ -46,7 +46,7 @@ def process_media_info(directory="downloads", log_dir="logs"):
46
46
  with open(log_file_path, "w", encoding="utf-8") as log_file:
47
47
  json.dump(media_info, log_file, indent=4)
48
48
  logger.info(f"Saved media information to: {log_file_path}")
49
- print(Fore.RED + "═" * 80 + Fore.RESET + "\n")
49
+ print(Fore.RED + "═" * 100 + Fore.RESET + "\n")
50
50
 
51
51
  except Exception as e:
52
52
  logger.error(f"Failed to process {file_path}: {e}")
@@ -56,8 +56,8 @@ def process_media_info(directory="downloads", log_dir="logs"):
56
56
  def main():
57
57
  clear_and_print()
58
58
  platform_name = detect_platform()
59
- logger.info("Downloading binaries... Please wait!")
60
- print(Fore.MAGENTA + "=" * 100 + Fore.RESET)
59
+ logger.info("Please be patient...")
60
+ print(Fore.RED + "" * 100 + Fore.RESET)
61
61
  time.sleep(1)
62
62
  bin_dir = Path(__file__).resolve().parent / "bin"
63
63
  download_binaries(bin_dir, platform_name)
@@ -72,47 +72,65 @@ def main():
72
72
 
73
73
  downloader = DOWNLOADER()
74
74
 
75
- if re.search(r"\.mpd\b", args.url, re.IGNORECASE):
76
- logger.info("DASH stream detected. Initializing DASH downloader...")
77
- elif re.search(r"\.m3u8\b", args.url, re.IGNORECASE):
78
- logger.info("HLS stream detected. Initializing HLS downloader...")
79
- elif re.search(r"\.ism\b", args.url, re.IGNORECASE):
80
- logger.info("ISM (Smooth Streaming) detected. Initializing ISM downloader...")
81
- else:
82
- logger.error("Unsupported URL format. Please provide a valid DASH (.mpd), HLS (.m3u8), or ISM (.ism) URL.")
83
- exit(1)
84
-
85
- downloader.manifest_url = args.url
86
- downloader.output_name = args.output
87
- downloader.decryption_keys = args.key or []
88
- downloader.headers = args.header or []
89
- downloader.proxy = args.proxy
90
-
91
- if downloader.proxy:
92
- if not downloader.proxy.startswith("http://"):
93
- downloader.proxy = f"http://{downloader.proxy}"
94
- logger.info(f"Proxy: {downloader.proxy}")
95
- print(Fore.RED + "═" * 80 + Fore.RESET + "\n")
96
-
97
- if downloader.headers:
98
- logger.info("Headers:")
99
- for header in downloader.headers:
100
- logger.info(f" - {header}")
101
- print(Fore.RED + "═" * 80 + Fore.RESET + "\n")
102
-
103
- if downloader.decryption_keys:
104
- logger.info("Decryption keys:")
105
- for key in downloader.decryption_keys:
106
- logger.info(f" - {key}")
107
- print(Fore.RED + "═" * 80 + Fore.RESET + "\n")
75
+ # Handle downloading if URL is provided
76
+ if args.url:
77
+ if re.search(r"\.mpd\b", args.url, re.IGNORECASE):
78
+ logger.info("DASH stream detected. Initializing DASH downloader...")
79
+ elif re.search(r"\.m3u8\b", args.url, re.IGNORECASE):
80
+ logger.info("HLS stream detected. Initializing HLS downloader...")
81
+ elif re.search(r"\.ism\b", args.url, re.IGNORECASE):
82
+ logger.info("ISM (Smooth Streaming) detected. Initializing ISM downloader...")
83
+ else:
84
+ logger.error("Unsupported URL format. Please provide a valid DASH (.mpd), HLS (.m3u8), or ISM (.ism) URL.")
85
+ exit(1)
86
+
87
+ downloader.manifest_url = args.url
88
+ downloader.output_name = args.output
89
+ downloader.decryption_keys = args.key or []
90
+ downloader.headers = args.header or []
91
+ downloader.proxy = args.proxy
92
+
93
+ if downloader.proxy:
94
+ if not downloader.proxy.startswith("http://"):
95
+ downloader.proxy = f"http://{downloader.proxy}"
96
+ logger.info(f"Proxy: {downloader.proxy}")
97
+ print(Fore.RED + "═" * 100 + Fore.RESET + "\n")
98
+
99
+ if downloader.headers:
100
+ logger.info("Headers:")
101
+ for header in downloader.headers:
102
+ logger.info(f" - {header}")
103
+ print(Fore.RED + "═" * 100 + Fore.RESET + "\n")
104
+
105
+ if downloader.decryption_keys:
106
+ logger.info("Decryption keys:")
107
+ for key in downloader.decryption_keys:
108
+ logger.info(f" - {key}")
109
+ print(Fore.RED + "═" * 100 + Fore.RESET + "\n")
108
110
 
109
- try:
110
- downloader.drm_downloader()
111
- except Exception as e:
112
- logger.error(f"An error occurred during the download process: {e}")
113
- exit(1)
114
-
115
- process_media_info(downloads_dir)
111
+ try:
112
+ downloader.drm_downloader()
113
+ except Exception as e:
114
+ logger.error(f"An error occurred during the download process: {e}")
115
+ exit(1)
116
+
117
+ process_media_info(downloads_dir)
118
+
119
+ if args.input and args.quality:
120
+ logger.info(f"Starting re-encode process for {args.input} to {args.quality.upper()} quality...")
121
+ output_file = downloader.re_encode_content(
122
+ input_file=args.input,
123
+ quality=args.quality,
124
+ codec="libx265",
125
+ crf=20,
126
+ preset="medium"
127
+ )
128
+
129
+ if output_file:
130
+ logger.info(f"Re-encoding completed successfully! Output saved to: {output_file}")
131
+ else:
132
+ logger.error("Re-encoding failed.")
133
+ exit(1)
116
134
 
117
135
  # =========================================================================================================== #
118
136
 
@@ -0,0 +1 @@
1
+ __version__ = "0.3.4"
@@ -10,11 +10,13 @@ def parse_arguments():
10
10
  )
11
11
 
12
12
  # Add arguments (these will not include the default descriptions)
13
- parser.add_argument("-u", "--url", required=True, help=argparse.SUPPRESS)
13
+ parser.add_argument("-u", "--url", help=argparse.SUPPRESS)
14
14
  parser.add_argument("-p", "--proxy", help=argparse.SUPPRESS)
15
- parser.add_argument("-o", "--output", required=True, help=argparse.SUPPRESS)
15
+ parser.add_argument("-o", "--output", help=argparse.SUPPRESS)
16
16
  parser.add_argument("-k", "--key", action="append", help=argparse.SUPPRESS)
17
17
  parser.add_argument("-H", "--header", action="append", help=argparse.SUPPRESS)
18
+ parser.add_argument("-i", "--input", help=argparse.SUPPRESS)
19
+ parser.add_argument("-q", "--quality", help=argparse.SUPPRESS)
18
20
  parser.add_argument(
19
21
  "-h", "--help",
20
22
  action="help",
@@ -23,7 +23,7 @@ def banners():
23
23
  stdout.write(""+Fore.YELLOW +"╔════════════════════════════════════════════════════════════════════════════╝\n")
24
24
  stdout.write(""+Fore.YELLOW +"║ \x1b[38;2;255;20;147m• "+Fore.GREEN+"GITHUB "+Fore.RED+" |"+Fore.LIGHTWHITE_EX+" GITHUB.COM/THATNOTEASY "+Fore.YELLOW+"║\n")
25
25
  stdout.write(""+Fore.YELLOW +"╚════════════════════════════════════════════════════════════════════════════╝\n")
26
- print(f"{Fore.YELLOW}[DDownloader] - {Fore.GREEN}Download DASH or HLS streams with decryption keys. - {Fore.RED}[V0.3.3] \n{Fore.RESET}")
26
+ print(f"{Fore.YELLOW}[DDownloader] - {Fore.GREEN}A DRM-Protected Content Downloader - {Fore.RED}[V0.3.4] \n{Fore.RESET}")
27
27
 
28
28
  # =========================================================================================================== #
29
29
 
@@ -37,16 +37,19 @@ def clear_and_print():
37
37
  def display_help():
38
38
  """Display custom help message with emoji."""
39
39
  print(
40
- f"{Fore.WHITE}+" + "=" * 100 + f"+{Style.RESET_ALL}\n"
40
+ f"{Fore.RED}.++" + "" * 100 + f"++.{Style.RESET_ALL}\n"
41
41
  f"{Fore.CYAN}{'Option':<40}{'Description':<90}{Style.RESET_ALL}\n"
42
- f"{Fore.WHITE}+" + "=" * 100 + f"+{Style.RESET_ALL}\n"
43
- f" {Fore.GREEN}-u, --url{' ' * 22}{Style.RESET_ALL}URL of the manifest (mpd/m3u8) 🌐\n"
42
+ f"{Fore.RED}.++" + "" * 100 + f"++.{Style.RESET_ALL}\n"
43
+ f" {Fore.GREEN}-u, --url{' ' * 22}{Style.RESET_ALL}URL of the manifest (mpd/m3u8/ism) 🌐\n"
44
44
  f" {Fore.GREEN}-p, --proxy{' ' * 20}{Style.RESET_ALL}A proxy with protocol (http://ip:port) 🌍\n"
45
45
  f" {Fore.GREEN}-o, --output{' ' * 19}{Style.RESET_ALL}Name of the output file 💾\n"
46
46
  f" {Fore.GREEN}-k, --key{' ' * 22}{Style.RESET_ALL}Decryption key in KID:KEY format 🔑\n"
47
47
  f" {Fore.GREEN}-H, --header{' ' * 19}{Style.RESET_ALL}Custom HTTP headers (e.g., User-Agent: value) 📋\n"
48
+ f"{Fore.RED}.++" + "═" * 100 + f"++.{Style.RESET_ALL}\n"
49
+ f" {Fore.GREEN}-i, --input{' ' * 20}{Style.RESET_ALL}Input file for re-encoding. 📂\n"
50
+ f" {Fore.GREEN}-q, --quality{' ' * 18}{Style.RESET_ALL}Target quality: HD, FHD, UHD. 🎥\n"
48
51
  f" {Fore.GREEN}-h, --help{' ' * 21}{Style.RESET_ALL}Show this help message and exit ❓\n"
49
- f"{Fore.WHITE}+" + "=" * 100 + f"+{Style.RESET_ALL}\n"
52
+ f"{Fore.RED}.++" + "" * 100 + f"++.{Style.RESET_ALL}\n"
50
53
  )
51
54
 
52
55
  # =========================================================================================================== #
@@ -0,0 +1,159 @@
1
+ import os
2
+ import subprocess
3
+ import logging
4
+ import platform
5
+ import coloredlogs
6
+ from colorama import Fore
7
+
8
+ logger = logging.getLogger(Fore.RED + "+ DDOWNLOADER + ")
9
+ coloredlogs.install(level='DEBUG', logger=logger)
10
+
11
+ class DOWNLOADER:
12
+ def __init__(self):
13
+ self.manifest_url = None
14
+ self.output_name = None
15
+ self.proxy = None
16
+ self.decryption_keys = []
17
+ self.headers = []
18
+ self.binary_path = None
19
+
20
+ # =========================================================================================================== #
21
+
22
+ def _get_binary_path(self, binary_type):
23
+ base_dir = os.path.dirname(os.path.abspath(__file__))
24
+ project_root = os.path.dirname(base_dir)
25
+ bin_dir = os.path.join(project_root, 'bin')
26
+
27
+ if binary_type == 'N_m3u8DL-RE':
28
+ binary_name = 'N_m3u8DL-RE.exe' if platform.system() == 'Windows' else 'N_m3u8DL-RE'
29
+ elif binary_type == 'ffmpeg':
30
+ binary_name = 'ffmpeg.exe' if platform.system() == 'Windows' else 'ffmpeg'
31
+ else:
32
+ raise ValueError(f"Unknown binary type: {binary_type}")
33
+
34
+ binary_path = os.path.join(bin_dir, binary_name)
35
+
36
+ if not os.path.isfile(binary_path):
37
+ logger.error(f"Binary not found: {binary_path}")
38
+ raise FileNotFoundError(f"Binary not found: {binary_path}")
39
+
40
+ if platform.system() == 'Linux':
41
+ chmod_command = ['chmod', '+x', binary_path]
42
+ try:
43
+ subprocess.run(chmod_command, check=True)
44
+ logger.info(Fore.CYAN + f"Set executable permission for: {binary_path}" + Fore.RESET)
45
+ except subprocess.CalledProcessError as e:
46
+ logger.error(Fore.RED + f"Failed to set executable permissions for: {binary_path}" + Fore.RESET)
47
+ raise RuntimeError(f"Could not set executable permissions for: {binary_path}") from e
48
+
49
+ return binary_path
50
+
51
+ # =========================================================================================================== #
52
+
53
+ def drm_downloader(self):
54
+ if not self.manifest_url:
55
+ logger.error("Manifest URL is not set.")
56
+ return
57
+ command = self._build_command()
58
+ self._execute_command(command)
59
+
60
+ # =========================================================================================================== #
61
+
62
+ def _build_command(self):
63
+ self.binary_path = self._get_binary_path("N_m3u8DL-RE")
64
+ command = [
65
+ self.binary_path,
66
+ f'"{self.manifest_url}"',
67
+ '--select-video', 'BEST',
68
+ '--select-audio', 'BEST',
69
+ '-mt',
70
+ '-M', 'format=mp4',
71
+ '--save-dir', '"downloads"',
72
+ '--tmp-dir', '"downloads"',
73
+ '--del-after-done',
74
+ '--save-name', f'"{self.output_name}"'
75
+ ]
76
+
77
+ for key in self.decryption_keys:
78
+ command.extend(['--key', f'"{key}"'])
79
+
80
+ if self.proxy:
81
+ if not self.proxy.startswith("http://"):
82
+ self.proxy = f"http://{self.proxy}"
83
+ command.extend(['--custom-proxy', f'"{self.proxy}"'])
84
+
85
+ for header in self.headers:
86
+ command.extend(['-H', f'"{header}"'])
87
+
88
+ return command
89
+
90
+ # =========================================================================================================== #
91
+
92
+ def _execute_command(self, command):
93
+ try:
94
+ command_str = ' '.join(command)
95
+ result = os.system(command_str)
96
+
97
+ if result == 0:
98
+ logger.info(Fore.GREEN + "Downloaded successfully. Bye!" + Fore.RESET)
99
+ print(Fore.RED + "═" * 100 + Fore.RESET + "\n")
100
+ else:
101
+ pass
102
+
103
+ except Exception as e:
104
+ logger.error(Fore.RED + f"An unexpected error occurred: {e}" + Fore.RESET)
105
+
106
+ # =========================================================================================================== #
107
+
108
+ def re_encode_content(self, input_file, quality, codec="libx265", crf=20, preset="medium", audio_bitrate="256k"):
109
+ resolutions = {
110
+ "HD": "1280:720",
111
+ "FHD": "1920:1080",
112
+ "UHD": "3840:2160"
113
+ }
114
+
115
+ quality = quality.upper()
116
+ if quality not in resolutions:
117
+ logger.error(f"Invalid quality '{quality}'. Choose from: HD, FHD, UHD.")
118
+ return None
119
+
120
+ input_file = os.path.abspath(input_file)
121
+ if not os.path.isfile(input_file):
122
+ logger.error(f"Input file does not exist: {input_file}")
123
+ return None
124
+
125
+ resolution = resolutions[quality]
126
+ base_name, ext = os.path.splitext(input_file)
127
+ output_file = os.path.abspath(f"{base_name}_{quality.lower()}{ext}")
128
+
129
+ self.binary_path = self._get_binary_path("ffmpeg")
130
+
131
+ logger.info(f"Re-encoding {input_file} to {quality} ({resolution}) using codec {codec}...")
132
+ logger.info(f"Output file: {output_file}")
133
+
134
+ os.makedirs(os.path.dirname(output_file), exist_ok=True)
135
+
136
+ # Build the ffmpeg command
137
+ command = [
138
+ self.binary_path,
139
+ "-i", f"\"{input_file}\"",
140
+ "-vf", f"scale={resolution}",
141
+ "-c:v", codec,
142
+ "-crf", str(crf),
143
+ "-preset", preset,
144
+ "-c:a", "aac",
145
+ "-b:a", audio_bitrate,
146
+ "-movflags", "+faststart",
147
+ f"\"{output_file}\""
148
+ ]
149
+
150
+ # Execute the command using `_execute_command`
151
+ self._execute_command(command)
152
+
153
+ # Check if output file exists to confirm success
154
+ if os.path.isfile(output_file):
155
+ logger.info(f"Re-encoding to {quality} completed successfully. Output saved to: {output_file}")
156
+ return output_file
157
+ else:
158
+ logger.error(f"Re-encoding failed. Output file not created: {output_file}")
159
+ return None
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.2
2
+ Name: DDownloader
3
+ Version: 0.3.4
4
+ Summary: A downloader for DRM-protected content.
5
+ Author-email: ThatNotEasy <apidotmy@proton.me>
6
+ License: MIT License
7
+
8
+ Copyright (c) [2024] [DDownloader]
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following condition:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26
+ IN THE SOFTWARE.
27
+ Classifier: Programming Language :: Python :: 3
28
+ Classifier: Programming Language :: Python :: 3.7
29
+ Classifier: Programming Language :: Python :: 3.8
30
+ Classifier: Programming Language :: Python :: 3.9
31
+ Classifier: Programming Language :: Python :: 3.10
32
+ Classifier: Programming Language :: Python :: 3.11
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Requires-Python: >=3.7
36
+ Description-Content-Type: text/markdown
37
+ License-File: LICENSE
38
+
39
+ # DDownloader
40
+ _DDownloader is a powerful Python-based tool and library designed to download and decrypt DRM-protected content from DASH, HLS, and ISM manifests. It provides seamless support for encrypted media streams, extracting metadata and ensuring high compatibility with various DRM standards._
41
+
42
+ ## Features
43
+ - **Download and Decrypt**: Supports DASH, HLS, and ISM manifests with seamless decryption using provided keys.
44
+ - **Automatic Detection**: Automatically detects manifest types (.mpd, .m3u8, .ism) and processes accordingly.
45
+ - **Media Information Extraction**: Extracts metadata (e.g., codec, resolution, duration) for .mp4 files and saves it in a `logs/` directory.
46
+ - **CLI and Library Support**: Flexible usage via command-line or Python library.
47
+ - **Detailed Logging**: Provides real-time progress and logs errors for debugging.
48
+
49
+ ## Requirements
50
+
51
+ - **Python**: Version 3.7 or higher.
52
+ - **Required binaries**:
53
+
54
+ - `N_m3u8DL-RE` for downloading protected DRM content.
55
+ - `mp4decrypt` for decrypting protected media files.
56
+ - `ffmpeg` for re-encoding and muxer method
57
+ - a proper environment variable configuration for binaries.
58
+
59
+ ## Installation
60
+ - Install `DDownloader` using pip:
61
+
62
+ ```bash
63
+ pip install DDownloader
64
+ ```
65
+
66
+ ## Usage
67
+ - Download Content:
68
+
69
+ ```python
70
+ from DDownloader.modules.downloader import DOWNLOADER
71
+
72
+ downloader = DOWNLOADER()
73
+ downloader.manifest_url = "https://example.com/path/to/manifest" # DASH, HLS, or ISM manifest URL
74
+ downloader.output_name = "output.mp4" # Desired output file name
75
+ downloader.decryption_keys = ["12345:678910"] # Provide decryption keys if needed
76
+ downloader.download() # Start the downloading and decryption process
77
+ ```
78
+
79
+ - Extract Media Information:
80
+
81
+ ```python
82
+ from DDownloader.modules.helper import get_media_info
83
+
84
+ file_path = "downloads/example.mp4"
85
+ media_info = get_media_info(file_path)
86
+ print(media_info)
87
+ ```
88
+
89
+ - Re-encoding:
90
+
91
+ ```python
92
+ from DDownloader.modules.downloader import DOWNLOADER
93
+
94
+ re_encode = DOWNLOADER()
95
+ quality = ["HD", "FHD", "UHD"]
96
+ input_content = "downloads/example.mp4"
97
+ output_content = "/path/to/output.mp4"
98
+ re_encode.re_encode_content(input_file=input_content,quality=quality,codec="libx265",crf=20,preset="medium")
99
+ ```
100
+
101
+ ## CLI Usage
102
+ - Download Media
103
+
104
+ ```bash
105
+ DDownloader -u https://example.com/path/to/manifest -o output.mp4
106
+ ```
107
+
108
+ - Specify Decryption Keys
109
+
110
+ ```bash
111
+ DDownloader -u https://example.com/path/to/manifest -o output.mp4 -k 12345:678910
112
+ ```
113
+
114
+ - Re-encoding
115
+
116
+ ```bash
117
+ DDownloader -i "input.mp4" -o "output.mp4" -q "HD, FHD, UHD"
118
+ ```
119
+
120
+
121
+ - Display Help
122
+
123
+ ```bash
124
+ DDownloader -h
125
+ ```
126
+
127
+ - ![image](https://github.com/user-attachments/assets/5698d535-b818-4566-80f2-44f588646c0f)
128
+
129
+ ## THIS PROJECT STILL IN DEVELOPMENT
130
+ - Contributions are welcome! Feel free to open issues, create pull requests, or provide suggestions.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.2
2
+ Name: DDownloader
3
+ Version: 0.3.4
4
+ Summary: A downloader for DRM-protected content.
5
+ Author-email: ThatNotEasy <apidotmy@proton.me>
6
+ License: MIT License
7
+
8
+ Copyright (c) [2024] [DDownloader]
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following condition:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26
+ IN THE SOFTWARE.
27
+ Classifier: Programming Language :: Python :: 3
28
+ Classifier: Programming Language :: Python :: 3.7
29
+ Classifier: Programming Language :: Python :: 3.8
30
+ Classifier: Programming Language :: Python :: 3.9
31
+ Classifier: Programming Language :: Python :: 3.10
32
+ Classifier: Programming Language :: Python :: 3.11
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Requires-Python: >=3.7
36
+ Description-Content-Type: text/markdown
37
+ License-File: LICENSE
38
+
39
+ # DDownloader
40
+ _DDownloader is a powerful Python-based tool and library designed to download and decrypt DRM-protected content from DASH, HLS, and ISM manifests. It provides seamless support for encrypted media streams, extracting metadata and ensuring high compatibility with various DRM standards._
41
+
42
+ ## Features
43
+ - **Download and Decrypt**: Supports DASH, HLS, and ISM manifests with seamless decryption using provided keys.
44
+ - **Automatic Detection**: Automatically detects manifest types (.mpd, .m3u8, .ism) and processes accordingly.
45
+ - **Media Information Extraction**: Extracts metadata (e.g., codec, resolution, duration) for .mp4 files and saves it in a `logs/` directory.
46
+ - **CLI and Library Support**: Flexible usage via command-line or Python library.
47
+ - **Detailed Logging**: Provides real-time progress and logs errors for debugging.
48
+
49
+ ## Requirements
50
+
51
+ - **Python**: Version 3.7 or higher.
52
+ - **Required binaries**:
53
+
54
+ - `N_m3u8DL-RE` for downloading protected DRM content.
55
+ - `mp4decrypt` for decrypting protected media files.
56
+ - `ffmpeg` for re-encoding and muxer method
57
+ - a proper environment variable configuration for binaries.
58
+
59
+ ## Installation
60
+ - Install `DDownloader` using pip:
61
+
62
+ ```bash
63
+ pip install DDownloader
64
+ ```
65
+
66
+ ## Usage
67
+ - Download Content:
68
+
69
+ ```python
70
+ from DDownloader.modules.downloader import DOWNLOADER
71
+
72
+ downloader = DOWNLOADER()
73
+ downloader.manifest_url = "https://example.com/path/to/manifest" # DASH, HLS, or ISM manifest URL
74
+ downloader.output_name = "output.mp4" # Desired output file name
75
+ downloader.decryption_keys = ["12345:678910"] # Provide decryption keys if needed
76
+ downloader.download() # Start the downloading and decryption process
77
+ ```
78
+
79
+ - Extract Media Information:
80
+
81
+ ```python
82
+ from DDownloader.modules.helper import get_media_info
83
+
84
+ file_path = "downloads/example.mp4"
85
+ media_info = get_media_info(file_path)
86
+ print(media_info)
87
+ ```
88
+
89
+ - Re-encoding:
90
+
91
+ ```python
92
+ from DDownloader.modules.downloader import DOWNLOADER
93
+
94
+ re_encode = DOWNLOADER()
95
+ quality = ["HD", "FHD", "UHD"]
96
+ input_content = "downloads/example.mp4"
97
+ output_content = "/path/to/output.mp4"
98
+ re_encode.re_encode_content(input_file=input_content,quality=quality,codec="libx265",crf=20,preset="medium")
99
+ ```
100
+
101
+ ## CLI Usage
102
+ - Download Media
103
+
104
+ ```bash
105
+ DDownloader -u https://example.com/path/to/manifest -o output.mp4
106
+ ```
107
+
108
+ - Specify Decryption Keys
109
+
110
+ ```bash
111
+ DDownloader -u https://example.com/path/to/manifest -o output.mp4 -k 12345:678910
112
+ ```
113
+
114
+ - Re-encoding
115
+
116
+ ```bash
117
+ DDownloader -i "input.mp4" -o "output.mp4" -q "HD, FHD, UHD"
118
+ ```
119
+
120
+
121
+ - Display Help
122
+
123
+ ```bash
124
+ DDownloader -h
125
+ ```
126
+
127
+ - ![image](https://github.com/user-attachments/assets/5698d535-b818-4566-80f2-44f588646c0f)
128
+
129
+ ## THIS PROJECT STILL IN DEVELOPMENT
130
+ - Contributions are welcome! Feel free to open issues, create pull requests, or provide suggestions.
@@ -0,0 +1,92 @@
1
+ # DDownloader
2
+ _DDownloader is a powerful Python-based tool and library designed to download and decrypt DRM-protected content from DASH, HLS, and ISM manifests. It provides seamless support for encrypted media streams, extracting metadata and ensuring high compatibility with various DRM standards._
3
+
4
+ ## Features
5
+ - **Download and Decrypt**: Supports DASH, HLS, and ISM manifests with seamless decryption using provided keys.
6
+ - **Automatic Detection**: Automatically detects manifest types (.mpd, .m3u8, .ism) and processes accordingly.
7
+ - **Media Information Extraction**: Extracts metadata (e.g., codec, resolution, duration) for .mp4 files and saves it in a `logs/` directory.
8
+ - **CLI and Library Support**: Flexible usage via command-line or Python library.
9
+ - **Detailed Logging**: Provides real-time progress and logs errors for debugging.
10
+
11
+ ## Requirements
12
+
13
+ - **Python**: Version 3.7 or higher.
14
+ - **Required binaries**:
15
+
16
+ - `N_m3u8DL-RE` for downloading protected DRM content.
17
+ - `mp4decrypt` for decrypting protected media files.
18
+ - `ffmpeg` for re-encoding and muxer method
19
+ - a proper environment variable configuration for binaries.
20
+
21
+ ## Installation
22
+ - Install `DDownloader` using pip:
23
+
24
+ ```bash
25
+ pip install DDownloader
26
+ ```
27
+
28
+ ## Usage
29
+ - Download Content:
30
+
31
+ ```python
32
+ from DDownloader.modules.downloader import DOWNLOADER
33
+
34
+ downloader = DOWNLOADER()
35
+ downloader.manifest_url = "https://example.com/path/to/manifest" # DASH, HLS, or ISM manifest URL
36
+ downloader.output_name = "output.mp4" # Desired output file name
37
+ downloader.decryption_keys = ["12345:678910"] # Provide decryption keys if needed
38
+ downloader.download() # Start the downloading and decryption process
39
+ ```
40
+
41
+ - Extract Media Information:
42
+
43
+ ```python
44
+ from DDownloader.modules.helper import get_media_info
45
+
46
+ file_path = "downloads/example.mp4"
47
+ media_info = get_media_info(file_path)
48
+ print(media_info)
49
+ ```
50
+
51
+ - Re-encoding:
52
+
53
+ ```python
54
+ from DDownloader.modules.downloader import DOWNLOADER
55
+
56
+ re_encode = DOWNLOADER()
57
+ quality = ["HD", "FHD", "UHD"]
58
+ input_content = "downloads/example.mp4"
59
+ output_content = "/path/to/output.mp4"
60
+ re_encode.re_encode_content(input_file=input_content,quality=quality,codec="libx265",crf=20,preset="medium")
61
+ ```
62
+
63
+ ## CLI Usage
64
+ - Download Media
65
+
66
+ ```bash
67
+ DDownloader -u https://example.com/path/to/manifest -o output.mp4
68
+ ```
69
+
70
+ - Specify Decryption Keys
71
+
72
+ ```bash
73
+ DDownloader -u https://example.com/path/to/manifest -o output.mp4 -k 12345:678910
74
+ ```
75
+
76
+ - Re-encoding
77
+
78
+ ```bash
79
+ DDownloader -i "input.mp4" -o "output.mp4" -q "HD, FHD, UHD"
80
+ ```
81
+
82
+
83
+ - Display Help
84
+
85
+ ```bash
86
+ DDownloader -h
87
+ ```
88
+
89
+ - ![image](https://github.com/user-attachments/assets/5698d535-b818-4566-80f2-44f588646c0f)
90
+
91
+ ## THIS PROJECT STILL IN DEVELOPMENT
92
+ - Contributions are welcome! Feel free to open issues, create pull requests, or provide suggestions.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "DDownloader"
7
- version = "0.3.3"
7
+ version = "0.3.4"
8
8
  description = "A downloader for DRM-protected content."
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  authors = [
@@ -25,7 +25,7 @@ classifiers = [
25
25
 
26
26
  [tool.poetry]
27
27
  name = "DDownloader"
28
- version = "0.3.3"
28
+ version = "0.3.4"
29
29
  description = "A downloader for DRM-protected content."
30
30
  authors = ["ThatNotEasy <apidotmy@proton.me>"]
31
31
  license = "MIT"
@@ -1 +0,0 @@
1
- __version__ = "0.3.3"
@@ -1,97 +0,0 @@
1
- import os
2
- import subprocess
3
- import logging
4
- import platform
5
- import coloredlogs
6
- from colorama import Fore
7
-
8
- logger = logging.getLogger(Fore.RED + "+ DASH + ")
9
- coloredlogs.install(level='DEBUG', logger=logger)
10
-
11
- class DOWNLOADER:
12
- def __init__(self):
13
- self.manifest_url = None
14
- self.output_name = None
15
- self.proxy = None
16
- self.decryption_keys = []
17
- self.headers = []
18
- self.binary_path = self._get_binary_path()
19
-
20
- # =========================================================================================================== #
21
-
22
- def _get_binary_path(self):
23
- base_dir = os.path.dirname(os.path.abspath(__file__))
24
- project_root = os.path.dirname(base_dir)
25
- bin_dir = os.path.join(project_root, 'bin')
26
-
27
- binary_name = 'N_m3u8DL-RE.exe' if platform.system() == 'Windows' else 'N_m3u8DL-RE'
28
- binary = os.path.join(bin_dir, binary_name)
29
-
30
- if not os.path.isfile(binary):
31
- logger.error(f"Binary not found: {binary}")
32
- raise FileNotFoundError(f"Binary not found: {binary}")
33
-
34
- if platform.system() == 'Linux':
35
- chmod_command = ['chmod', '+x', binary]
36
- try:
37
- subprocess.run(chmod_command, check=True)
38
- logger.info(Fore.CYAN + f"Set executable permission for: {binary}" + Fore.RESET)
39
- except subprocess.CalledProcessError as e:
40
- logger.error(Fore.RED + f"Failed to set executable permissions for: {binary}" + Fore.RESET)
41
- raise RuntimeError(f"Could not set executable permissions for: {binary}") from e
42
- return binary
43
-
44
- # =========================================================================================================== #
45
-
46
- def drm_downloader(self):
47
- if not self.manifest_url:
48
- logger.error("Manifest URL is not set.")
49
- return
50
- command = self._build_command()
51
- self._execute_command(command)
52
-
53
- # =========================================================================================================== #
54
-
55
- def _build_command(self):
56
- command = [
57
- self.binary_path,
58
- f'"{self.manifest_url}"',
59
- '--select-video', 'BEST',
60
- '--select-audio', 'BEST',
61
- '-mt',
62
- '-M', 'format=mp4',
63
- '--save-dir', '"downloads"',
64
- '--tmp-dir', '"downloads"',
65
- '--del-after-done',
66
- '--save-name', f'"{self.output_name}"'
67
- ]
68
-
69
- for key in self.decryption_keys:
70
- command.extend(['--key', f'"{key}"'])
71
-
72
- if self.proxy:
73
- if not self.proxy.startswith("http://"):
74
- self.proxy = f"http://{self.proxy}"
75
- command.extend(['--custom-proxy', f'"{self.proxy}"'])
76
-
77
- for header in self.headers:
78
- command.extend(['-H', f'"{header}"'])
79
-
80
- return command
81
-
82
- # =========================================================================================================== #
83
-
84
- def _execute_command(self, command):
85
- try:
86
- command_str = ' '.join(command)
87
- result = os.system(command_str)
88
-
89
- if result == 0:
90
- logger.info(Fore.GREEN + "Downloaded successfully. Bye!" + Fore.RESET)
91
- else:
92
- pass
93
-
94
- except Exception as e:
95
- logger.error(Fore.RED + f"An unexpected error occurred: {e}" + Fore.RESET)
96
-
97
- # =========================================================================================================== #
@@ -1,89 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: DDownloader
3
- Version: 0.3.3
4
- Summary: A downloader for DRM-protected content.
5
- Author-email: ThatNotEasy <apidotmy@proton.me>
6
- License: MIT License
7
-
8
- Copyright (c) [2024] [DDownloader]
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following condition:
16
-
17
- The above copyright notice and this permission notice shall be included in
18
- all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26
- IN THE SOFTWARE.
27
- Classifier: Programming Language :: Python :: 3
28
- Classifier: Programming Language :: Python :: 3.7
29
- Classifier: Programming Language :: Python :: 3.8
30
- Classifier: Programming Language :: Python :: 3.9
31
- Classifier: Programming Language :: Python :: 3.10
32
- Classifier: Programming Language :: Python :: 3.11
33
- Classifier: License :: OSI Approved :: MIT License
34
- Classifier: Operating System :: OS Independent
35
- Requires-Python: >=3.7
36
- Description-Content-Type: text/markdown
37
- License-File: LICENSE
38
-
39
- # DDownloader
40
- - DDownloader is a Python library to download HLS and DASH manifests and decrypt media files.
41
-
42
- # Features
43
- - Download HLS streams using N_m3u8DL-RE.
44
- - Download DASH manifests and segments.
45
- - Decrypt media files using mp4decrypt.
46
-
47
- # Footprints Notes:
48
- - It is better if you have set your own environment variables.
49
-
50
- # Installation
51
- Use the package manager pip to install DDownloader.
52
- ```pip install DDownloader```
53
-
54
- # Usage
55
-
56
- - Download DASH content using the library:
57
-
58
- ```python
59
- from DDownloader.dash_downloader import DASH
60
-
61
- dash_downloader = DASH()
62
- dash_downloader.manifest_url = "https://example.com/path/to/manifest.mpd" # Set your DASH manifest URL
63
- dash_downloader.output_name = "output.mp4" # Set desired output name
64
- dash_downloader.decryption_key = "12345:678910" # Set decryption key if needed
65
- dash_downloader.dash_downloader()
66
- ```
67
-
68
- - Download HLS content using the library:
69
- ```python
70
- from DDownloader.hls_downloader import HLS
71
-
72
- hls_downloader = HLS()
73
- hls_downloader.manifest_url = "https://example.com/path/to/manifest.m3u8" # Set your HLS manifest URL
74
- hls_downloader.output_name = "output.mp4" # Set desired output name
75
- hls_downloader.decryption_key = "12345:678910" # Set decryption key if needed
76
- hls_downloader.hls_downloader() # Call the downloader method
77
- ```
78
-
79
- - CLI Usage:
80
- ```bash
81
- DDownloader -h
82
- ```
83
-
84
- - ![image](https://github.com/user-attachments/assets/5abdee78-2bb3-45be-b784-c8de86dac237)
85
-
86
-
87
- ## THIS PROJECT STILL IN DEVELOPMENT
88
-
89
- - Contributions are welcome! Feel free to open issues, create pull requests, or provide suggestions.
@@ -1,89 +0,0 @@
1
- Metadata-Version: 2.2
2
- Name: DDownloader
3
- Version: 0.3.3
4
- Summary: A downloader for DRM-protected content.
5
- Author-email: ThatNotEasy <apidotmy@proton.me>
6
- License: MIT License
7
-
8
- Copyright (c) [2024] [DDownloader]
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following condition:
16
-
17
- The above copyright notice and this permission notice shall be included in
18
- all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26
- IN THE SOFTWARE.
27
- Classifier: Programming Language :: Python :: 3
28
- Classifier: Programming Language :: Python :: 3.7
29
- Classifier: Programming Language :: Python :: 3.8
30
- Classifier: Programming Language :: Python :: 3.9
31
- Classifier: Programming Language :: Python :: 3.10
32
- Classifier: Programming Language :: Python :: 3.11
33
- Classifier: License :: OSI Approved :: MIT License
34
- Classifier: Operating System :: OS Independent
35
- Requires-Python: >=3.7
36
- Description-Content-Type: text/markdown
37
- License-File: LICENSE
38
-
39
- # DDownloader
40
- - DDownloader is a Python library to download HLS and DASH manifests and decrypt media files.
41
-
42
- # Features
43
- - Download HLS streams using N_m3u8DL-RE.
44
- - Download DASH manifests and segments.
45
- - Decrypt media files using mp4decrypt.
46
-
47
- # Footprints Notes:
48
- - It is better if you have set your own environment variables.
49
-
50
- # Installation
51
- Use the package manager pip to install DDownloader.
52
- ```pip install DDownloader```
53
-
54
- # Usage
55
-
56
- - Download DASH content using the library:
57
-
58
- ```python
59
- from DDownloader.dash_downloader import DASH
60
-
61
- dash_downloader = DASH()
62
- dash_downloader.manifest_url = "https://example.com/path/to/manifest.mpd" # Set your DASH manifest URL
63
- dash_downloader.output_name = "output.mp4" # Set desired output name
64
- dash_downloader.decryption_key = "12345:678910" # Set decryption key if needed
65
- dash_downloader.dash_downloader()
66
- ```
67
-
68
- - Download HLS content using the library:
69
- ```python
70
- from DDownloader.hls_downloader import HLS
71
-
72
- hls_downloader = HLS()
73
- hls_downloader.manifest_url = "https://example.com/path/to/manifest.m3u8" # Set your HLS manifest URL
74
- hls_downloader.output_name = "output.mp4" # Set desired output name
75
- hls_downloader.decryption_key = "12345:678910" # Set decryption key if needed
76
- hls_downloader.hls_downloader() # Call the downloader method
77
- ```
78
-
79
- - CLI Usage:
80
- ```bash
81
- DDownloader -h
82
- ```
83
-
84
- - ![image](https://github.com/user-attachments/assets/5abdee78-2bb3-45be-b784-c8de86dac237)
85
-
86
-
87
- ## THIS PROJECT STILL IN DEVELOPMENT
88
-
89
- - Contributions are welcome! Feel free to open issues, create pull requests, or provide suggestions.
@@ -1,51 +0,0 @@
1
- # DDownloader
2
- - DDownloader is a Python library to download HLS and DASH manifests and decrypt media files.
3
-
4
- # Features
5
- - Download HLS streams using N_m3u8DL-RE.
6
- - Download DASH manifests and segments.
7
- - Decrypt media files using mp4decrypt.
8
-
9
- # Footprints Notes:
10
- - It is better if you have set your own environment variables.
11
-
12
- # Installation
13
- Use the package manager pip to install DDownloader.
14
- ```pip install DDownloader```
15
-
16
- # Usage
17
-
18
- - Download DASH content using the library:
19
-
20
- ```python
21
- from DDownloader.dash_downloader import DASH
22
-
23
- dash_downloader = DASH()
24
- dash_downloader.manifest_url = "https://example.com/path/to/manifest.mpd" # Set your DASH manifest URL
25
- dash_downloader.output_name = "output.mp4" # Set desired output name
26
- dash_downloader.decryption_key = "12345:678910" # Set decryption key if needed
27
- dash_downloader.dash_downloader()
28
- ```
29
-
30
- - Download HLS content using the library:
31
- ```python
32
- from DDownloader.hls_downloader import HLS
33
-
34
- hls_downloader = HLS()
35
- hls_downloader.manifest_url = "https://example.com/path/to/manifest.m3u8" # Set your HLS manifest URL
36
- hls_downloader.output_name = "output.mp4" # Set desired output name
37
- hls_downloader.decryption_key = "12345:678910" # Set decryption key if needed
38
- hls_downloader.hls_downloader() # Call the downloader method
39
- ```
40
-
41
- - CLI Usage:
42
- ```bash
43
- DDownloader -h
44
- ```
45
-
46
- - ![image](https://github.com/user-attachments/assets/5abdee78-2bb3-45be-b784-c8de86dac237)
47
-
48
-
49
- ## THIS PROJECT STILL IN DEVELOPMENT
50
-
51
- - Contributions are welcome! Feel free to open issues, create pull requests, or provide suggestions.
File without changes
File without changes