yt-dlp-host-api 0.1.2__py3-none-any.whl → 0.2.0__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.
- yt_dlp_host_api/client.py +47 -16
- {yt_dlp_host_api-0.1.2.dist-info → yt_dlp_host_api-0.2.0.dist-info}/METADATA +70 -24
- yt_dlp_host_api-0.2.0.dist-info/RECORD +10 -0
- {yt_dlp_host_api-0.1.2.dist-info → yt_dlp_host_api-0.2.0.dist-info}/WHEEL +1 -1
- yt_dlp_host_api-0.1.2.dist-info/RECORD +0 -10
- {yt_dlp_host_api-0.1.2.dist-info → yt_dlp_host_api-0.2.0.dist-info/licenses}/LICENSE +0 -0
- {yt_dlp_host_api-0.1.2.dist-info → yt_dlp_host_api-0.2.0.dist-info}/top_level.txt +0 -0
yt_dlp_host_api/client.py
CHANGED
@@ -9,38 +9,44 @@ class Client:
|
|
9
9
|
self.headers = {"X-API-Key": api_key, "Content-Type": "application/json"}
|
10
10
|
self.send_task = self.SendTask(self)
|
11
11
|
|
12
|
-
def get_video(self, url, video_format="bestvideo", audio_format="bestaudio", start_time=None, end_time=None):
|
12
|
+
def get_video(self, url, video_format="bestvideo", audio_format="bestaudio", output_format="mp4", start_time=None, end_time=None, force_keyframes=False):
|
13
13
|
return self.send_task.get_video(
|
14
14
|
url=url,
|
15
15
|
video_format=video_format,
|
16
16
|
audio_format=audio_format,
|
17
|
+
output_format=output_format,
|
17
18
|
start_time=start_time,
|
18
|
-
end_time=end_time
|
19
|
+
end_time=end_time,
|
20
|
+
force_keyframes=force_keyframes
|
19
21
|
).get_result()
|
20
22
|
|
21
|
-
def get_audio(self, url, audio_format="bestaudio", start_time=None, end_time=None):
|
23
|
+
def get_audio(self, url, audio_format="bestaudio", output_format=None, start_time=None, end_time=None, force_keyframes=False):
|
22
24
|
return self.send_task.get_audio(
|
23
25
|
url=url,
|
24
26
|
audio_format=audio_format,
|
27
|
+
output_format=output_format,
|
25
28
|
start_time=start_time,
|
26
|
-
end_time=end_time
|
29
|
+
end_time=end_time,
|
30
|
+
force_keyframes=force_keyframes
|
27
31
|
).get_result()
|
28
32
|
|
29
|
-
def get_live_video(self, url, duration, start=0, video_format="bestvideo", audio_format="bestaudio"):
|
33
|
+
def get_live_video(self, url, duration, start=0, video_format="bestvideo", audio_format="bestaudio", output_format="mp4"):
|
30
34
|
return self.send_task.get_live_video(
|
31
35
|
url=url,
|
32
36
|
start=start,
|
33
37
|
duration=duration,
|
34
38
|
video_format=video_format,
|
35
|
-
audio_format=audio_format
|
39
|
+
audio_format=audio_format,
|
40
|
+
output_format=output_format
|
36
41
|
).get_result()
|
37
42
|
|
38
|
-
def get_live_audio(self, url, duration, start=0, audio_format="bestaudio"):
|
43
|
+
def get_live_audio(self, url, duration, start=0, audio_format="bestaudio", output_format=None):
|
39
44
|
return self.send_task.get_live_audio(
|
40
45
|
url=url,
|
41
46
|
start=start,
|
42
47
|
duration=duration,
|
43
|
-
audio_format=audio_format
|
48
|
+
audio_format=audio_format,
|
49
|
+
output_format=output_format
|
44
50
|
).get_result()
|
45
51
|
|
46
52
|
def get_info(self, url):
|
@@ -84,8 +90,14 @@ class Client:
|
|
84
90
|
def __init__(self, client):
|
85
91
|
self.client = client
|
86
92
|
|
87
|
-
def get_video(self, url, video_format="bestvideo", audio_format="bestaudio", start_time=None, end_time=None):
|
88
|
-
data = {
|
93
|
+
def get_video(self, url, video_format="bestvideo", audio_format="bestaudio", output_format="mp4", start_time=None, end_time=None, force_keyframes=False):
|
94
|
+
data = {
|
95
|
+
"url": url,
|
96
|
+
"video_format": video_format,
|
97
|
+
"audio_format": audio_format,
|
98
|
+
"output_format": output_format,
|
99
|
+
"force_keyframes": force_keyframes
|
100
|
+
}
|
89
101
|
if start_time is not None: data["start_time"] = start_time
|
90
102
|
if end_time is not None: data["end_time"] = end_time
|
91
103
|
|
@@ -94,8 +106,13 @@ class Client:
|
|
94
106
|
raise APIError(response.json().get('error', 'Unknown error'))
|
95
107
|
return Task(self.client, response.json()['task_id'], 'get_video')
|
96
108
|
|
97
|
-
def get_audio(self, url, audio_format="bestaudio", start_time=None, end_time=None):
|
98
|
-
data = {
|
109
|
+
def get_audio(self, url, audio_format="bestaudio", output_format=None, start_time=None, end_time=None, force_keyframes=False):
|
110
|
+
data = {
|
111
|
+
"url": url,
|
112
|
+
"audio_format": audio_format,
|
113
|
+
"force_keyframes": force_keyframes
|
114
|
+
}
|
115
|
+
if output_format is not None: data["output_format"] = output_format
|
99
116
|
if start_time is not None: data["start_time"] = start_time
|
100
117
|
if end_time is not None: data["end_time"] = end_time
|
101
118
|
|
@@ -104,15 +121,29 @@ class Client:
|
|
104
121
|
raise APIError(response.json().get('error', 'Unknown error'))
|
105
122
|
return Task(self.client, response.json()['task_id'], 'get_audio')
|
106
123
|
|
107
|
-
def get_live_video(self, url, duration, start=0, video_format="bestvideo", audio_format="bestaudio"):
|
108
|
-
data = {
|
124
|
+
def get_live_video(self, url, duration, start=0, video_format="bestvideo", audio_format="bestaudio", output_format="mp4"):
|
125
|
+
data = {
|
126
|
+
"url": url,
|
127
|
+
"start": start,
|
128
|
+
"duration": duration,
|
129
|
+
"video_format": video_format,
|
130
|
+
"audio_format": audio_format,
|
131
|
+
"output_format": output_format
|
132
|
+
}
|
109
133
|
response = requests.post(f"{self.client.host_url}/get_live_video", json=data, headers=self.client.headers)
|
110
134
|
if response.status_code != 200:
|
111
135
|
raise APIError(response.json().get('error', 'Unknown error'))
|
112
136
|
return Task(self.client, response.json()['task_id'], 'get_video')
|
113
137
|
|
114
|
-
def get_live_audio(self, url, duration, start=0, audio_format="bestaudio"):
|
115
|
-
data = {
|
138
|
+
def get_live_audio(self, url, duration, start=0, audio_format="bestaudio", output_format=None):
|
139
|
+
data = {
|
140
|
+
"url": url,
|
141
|
+
"start": start,
|
142
|
+
"duration": duration,
|
143
|
+
"audio_format": audio_format
|
144
|
+
}
|
145
|
+
if output_format is not None: data["output_format"] = output_format
|
146
|
+
|
116
147
|
response = requests.post(f"{self.client.host_url}/get_live_audio", json=data, headers=self.client.headers)
|
117
148
|
if response.status_code != 200:
|
118
149
|
raise APIError(response.json().get('error', 'Unknown error'))
|
@@ -1,17 +1,18 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: yt_dlp_host_api
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: A Python library for interacting with the yt-dlp-host API
|
5
5
|
Author-email: "Amadeus (Wasys)" <tubik.corp@gmail.com>
|
6
|
+
License-Expression: MIT
|
6
7
|
Project-URL: Homepage, https://github.com/Vasysik/yt-dlp-host-api
|
7
8
|
Project-URL: Issues, https://github.com/Vasysik/yt-dlp-host-api/issues
|
8
9
|
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
10
10
|
Classifier: Operating System :: OS Independent
|
11
11
|
Requires-Python: >=3.8
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
License-File: LICENSE
|
14
|
-
Requires-Dist: requests
|
14
|
+
Requires-Dist: requests>=2.25.1
|
15
|
+
Dynamic: license-file
|
15
16
|
|
16
17
|
# [yt-dlp-host](https://github.com/Vasysik/yt-dlp-host) API Client
|
17
18
|
|
@@ -36,29 +37,42 @@ import yt_dlp_host_api
|
|
36
37
|
api = yt_dlp_host_api.api('http://your-api-url.com')
|
37
38
|
client = api.get_client('YOUR_API_KEY')
|
38
39
|
|
39
|
-
# Download a complete video
|
40
|
-
client.get_video(url='https://youtu.be/1FPdtR_5KFo').save_file("test_video.mp4")
|
40
|
+
# Download a complete video in MP4 format
|
41
|
+
client.get_video(url='https://youtu.be/1FPdtR_5KFo', output_format='mp4').save_file("test_video.mp4")
|
41
42
|
print("Video saved to test_video.mp4")
|
42
43
|
|
43
|
-
# Download a video
|
44
|
+
# Download a video in WebM format
|
45
|
+
client.get_video(url='https://youtu.be/1FPdtR_5KFo', output_format='webm').save_file("test_video.webm")
|
46
|
+
print("Video saved to test_video.webm")
|
47
|
+
|
48
|
+
# Download a video segment with precise cutting
|
44
49
|
client.get_video(
|
45
50
|
url='https://youtu.be/1FPdtR_5KFo',
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
output_format='mkv',
|
52
|
+
start_time="00:05:00",
|
53
|
+
end_time="00:10:00",
|
54
|
+
force_keyframes=True
|
55
|
+
).save_file("precise_cut.mkv")
|
56
|
+
print("Precisely cut segment saved to precise_cut.mkv")
|
49
57
|
|
50
|
-
# Download a video segment
|
58
|
+
# Download a video segment with faster cutting at keyframes
|
51
59
|
client.get_video(
|
52
60
|
url='https://youtu.be/1FPdtR_5KFo',
|
61
|
+
output_format='mp4',
|
53
62
|
start_time="00:05:00",
|
54
|
-
end_time="00:10:00"
|
55
|
-
|
56
|
-
|
63
|
+
end_time="00:10:00",
|
64
|
+
force_keyframes=False
|
65
|
+
).save_file("keyframe_cut.mp4")
|
66
|
+
print("Keyframe-cut segment saved to keyframe_cut.mp4")
|
57
67
|
|
58
|
-
# Download a complete audio
|
59
|
-
client.get_audio(url='https://youtu.be/1FPdtR_5KFo').save_file("test_audio.mp3")
|
68
|
+
# Download a complete audio in MP3 format
|
69
|
+
client.get_audio(url='https://youtu.be/1FPdtR_5KFo', output_format='mp3').save_file("test_audio.mp3")
|
60
70
|
print("Audio saved to test_audio.mp3")
|
61
71
|
|
72
|
+
# Download audio in FLAC format (lossless)
|
73
|
+
client.get_audio(url='https://youtu.be/1FPdtR_5KFo', output_format='flac').save_file("test_audio.flac")
|
74
|
+
print("Audio saved to test_audio.flac")
|
75
|
+
|
62
76
|
# Get info
|
63
77
|
info_json = client.get_info(url='https://youtu.be/1FPdtR_5KFo').get_json(['qualities', 'title'])
|
64
78
|
print("Video info:", info_json)
|
@@ -75,11 +89,15 @@ client.delete_key("user_key")
|
|
75
89
|
- Download YouTube videos
|
76
90
|
- Download complete videos
|
77
91
|
- Download specific time segments
|
92
|
+
- Precise cutting with frame re-encoding
|
93
|
+
- Fast cutting at keyframes
|
78
94
|
- Choose video and audio quality
|
95
|
+
- Choose output format (MP4, MKV, WebM, AVI, MOV, FLV, 3GP)
|
79
96
|
- Download YouTube audio
|
80
97
|
- Download complete audio
|
81
98
|
- Download specific time segments
|
82
99
|
- Choose audio quality
|
100
|
+
- Choose output format (MP3, M4A, Opus, FLAC, WAV, AAC, OGG)
|
83
101
|
- Extract live stream segments
|
84
102
|
- Retrieve video information
|
85
103
|
- Checking client permissions
|
@@ -93,18 +111,40 @@ client.delete_key("user_key")
|
|
93
111
|
|
94
112
|
### Client
|
95
113
|
|
96
|
-
- `client.get_video(url, video_format="bestvideo", audio_format="bestaudio", start_time=None, end_time=None)`: Get video with optional time segment selection
|
97
|
-
- `client.get_audio(url, audio_format="bestaudio", start_time=None, end_time=None)`: Get audio with optional time segment selection
|
98
|
-
- `client.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio")`: Get live video segment
|
99
|
-
- `client.get_live_audio(url, duration, start=0, audio_format="bestaudio")`: Get live audio segment
|
114
|
+
- `client.get_video(url, video_format="bestvideo", audio_format="bestaudio", output_format="mp4", start_time=None, end_time=None, force_keyframes=False)`: Get video with optional time segment selection
|
115
|
+
- `client.get_audio(url, audio_format="bestaudio", output_format=None, start_time=None, end_time=None, force_keyframes=False)`: Get audio with optional time segment selection
|
116
|
+
- `client.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio", output_format="mp4")`: Get live video segment
|
117
|
+
- `client.get_live_audio(url, duration, start=0, audio_format="bestaudio", output_format=None)`: Get live audio segment
|
100
118
|
- `client.get_info(url)`: Get video information
|
101
|
-
- `client.send_task.get_video(url, video_format="bestvideo", audio_format="bestaudio", start_time=None, end_time=None)`: Initiate a video download task
|
102
|
-
- `client.send_task.get_audio(url, audio_format="bestaudio", start_time=None, end_time=None)`: Initiate an audio download task
|
103
|
-
- `client.send_task.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio")`: Initiate a live video download task
|
104
|
-
- `client.send_task.get_live_audio(url, duration, start=0, audio_format="bestaudio")`: Initiate a live audio download task
|
119
|
+
- `client.send_task.get_video(url, video_format="bestvideo", audio_format="bestaudio", output_format="mp4", start_time=None, end_time=None, force_keyframes=False)`: Initiate a video download task
|
120
|
+
- `client.send_task.get_audio(url, audio_format="bestaudio", output_format=None, start_time=None, end_time=None, force_keyframes=False)`: Initiate an audio download task
|
121
|
+
- `client.send_task.get_live_video(url, duration, start=0, video_format="bestvideo", audio_format="bestaudio", output_format="mp4")`: Initiate a live video download task
|
122
|
+
- `client.send_task.get_live_audio(url, duration, start=0, audio_format="bestaudio", output_format=None)`: Initiate a live audio download task
|
105
123
|
- `client.send_task.get_info(url)`: Initiate an info retrieval task
|
106
124
|
- `client.check_permissions(permissions)`: Check for all permissions in the list
|
107
125
|
|
126
|
+
### Supported Output Formats
|
127
|
+
|
128
|
+
#### Video Formats
|
129
|
+
- **mp4** - MPEG-4 Part 14 (recommended)
|
130
|
+
- **mkv** - Matroska
|
131
|
+
- **webm** - WebM
|
132
|
+
- **avi** - Audio Video Interleave
|
133
|
+
- **mov** - QuickTime File Format
|
134
|
+
- **flv** - Flash Video
|
135
|
+
- **3gp** - 3GPP multimedia
|
136
|
+
|
137
|
+
#### Audio Formats
|
138
|
+
- **mp3** - MPEG Audio Layer III
|
139
|
+
- **m4a** - MPEG-4 Audio
|
140
|
+
- **opus** - Opus Audio
|
141
|
+
- **flac** - Free Lossless Audio Codec
|
142
|
+
- **wav** - Waveform Audio File Format
|
143
|
+
- **aac** - Advanced Audio Coding
|
144
|
+
- **ogg** - Ogg Vorbis
|
145
|
+
|
146
|
+
Note: If `output_format` is not specified for audio, the original format will be used.
|
147
|
+
|
108
148
|
### Time Format
|
109
149
|
|
110
150
|
Time parameters (`start_time` and `end_time`) should be provided in the following format:
|
@@ -113,6 +153,12 @@ Examples:
|
|
113
153
|
- "00:05:00" - 5 minutes
|
114
154
|
- "01:30:45" - 1 hour, 30 minutes, and 45 seconds
|
115
155
|
|
156
|
+
### Cutting Modes
|
157
|
+
|
158
|
+
The `force_keyframes` parameter determines how video/audio segments are cut:
|
159
|
+
- `force_keyframes=False` (default): Faster cutting that aligns to nearest keyframes. May not be exactly at specified timestamps but is much faster as it avoids re-encoding.
|
160
|
+
- `force_keyframes=True`: Precise cutting at exact timestamps. This requires re-encoding which takes longer but provides exact cuts.
|
161
|
+
|
116
162
|
### Task
|
117
163
|
|
118
164
|
- `task.get_status()`: Get the current status of a task
|
@@ -0,0 +1,10 @@
|
|
1
|
+
yt_dlp_host_api/__init__.py,sha256=RHx1BvH2Cy_dweEKo5sA-hdBOfBdY_2ds7srPuKGzWQ,41
|
2
|
+
yt_dlp_host_api/api.py,sha256=iLzWKoyiXeu0Y1Uky8PzpxxHTSMcTGzxlCRT121AKcM,196
|
3
|
+
yt_dlp_host_api/client.py,sha256=5Wf7Ue0A1HQX2EuaBk_TndOpWoDlb6t5NBslB0EljGI,7432
|
4
|
+
yt_dlp_host_api/exceptions.py,sha256=U_70W1R_ZcUfKptUShGB5VPWQXwc5M29_sNC8pwwq8g,38
|
5
|
+
yt_dlp_host_api/task.py,sha256=llgBAO_L1CajklMsbICdRpLdOV05Wi0oUh9NKj0bD0w,2674
|
6
|
+
yt_dlp_host_api-0.2.0.dist-info/licenses/LICENSE,sha256=-_Ad_xue4UymJ8jO-ZsSg0vmZ6SUm8WYdoEwHLyBUlc,1078
|
7
|
+
yt_dlp_host_api-0.2.0.dist-info/METADATA,sha256=NBsJNdGgaSDD3z5Q-S7Sd1ZdjuXbQm8k_064IfMVBf0,7368
|
8
|
+
yt_dlp_host_api-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
yt_dlp_host_api-0.2.0.dist-info/top_level.txt,sha256=Mn3FZuqLCHr47sRjhtEOz7lDl4lpsHkymWANORYp72s,16
|
10
|
+
yt_dlp_host_api-0.2.0.dist-info/RECORD,,
|
@@ -1,10 +0,0 @@
|
|
1
|
-
yt_dlp_host_api/__init__.py,sha256=RHx1BvH2Cy_dweEKo5sA-hdBOfBdY_2ds7srPuKGzWQ,41
|
2
|
-
yt_dlp_host_api/api.py,sha256=iLzWKoyiXeu0Y1Uky8PzpxxHTSMcTGzxlCRT121AKcM,196
|
3
|
-
yt_dlp_host_api/client.py,sha256=6vGRfZ0WMLSzW_4pDGRL1_Nc8lDKZA2GkgFMxiXL_kI,6226
|
4
|
-
yt_dlp_host_api/exceptions.py,sha256=U_70W1R_ZcUfKptUShGB5VPWQXwc5M29_sNC8pwwq8g,38
|
5
|
-
yt_dlp_host_api/task.py,sha256=llgBAO_L1CajklMsbICdRpLdOV05Wi0oUh9NKj0bD0w,2674
|
6
|
-
yt_dlp_host_api-0.1.2.dist-info/LICENSE,sha256=-_Ad_xue4UymJ8jO-ZsSg0vmZ6SUm8WYdoEwHLyBUlc,1078
|
7
|
-
yt_dlp_host_api-0.1.2.dist-info/METADATA,sha256=E-J-hWokh7CGbGGCiphoh40ye_W-GgcVvViFi2VNurM,5311
|
8
|
-
yt_dlp_host_api-0.1.2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
9
|
-
yt_dlp_host_api-0.1.2.dist-info/top_level.txt,sha256=Mn3FZuqLCHr47sRjhtEOz7lDl4lpsHkymWANORYp72s,16
|
10
|
-
yt_dlp_host_api-0.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|