-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubdl.py
More file actions
36 lines (19 loc) · 769 Bytes
/
Copy pathsubdl.py
File metadata and controls
36 lines (19 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import requests, time
api_key = ''
def Subtitle(title: str, IMDD_ID: str, page = 1):
print(f'This is page: {page}\n\n\n\n')
r = requests.get(f'https://api.subdl.com/api/v1/subtitles?imdb_id={IMDD_ID}&subs_per_page=30&languages=ar&page={page}&api_key={api_key}')
if Check_Rate(r):
time.sleep(60 * 10)
return Subtitle(title, IMDD_ID, page)
return r.json()
def Get_Pages(title: str, IMDD_ID: str) -> int:
return int(Subtitle(title, IMDD_ID)['totalPages'])
def Download(subtitle_url: str):
r = requests.get(f'https://dl.subdl.com{subtitle_url}?api_key={api_key}', stream=True)
return r.content
def Check_Rate(req):
if req.status_code ==429:
return True
else:
False