88 lines
2.4 KiB
Python
88 lines
2.4 KiB
Python
import requests, time
|
|
|
|
|
|
SDAROT_DOMAIN = "sdarot.buzz"
|
|
|
|
|
|
def get_sdarot_cookies():
|
|
return { "Sdarot": requests.get(f"https://{SDAROT_DOMAIN}/index").cookies["Sdarot"] }
|
|
|
|
|
|
|
|
def login_to_sdarot_tv(username, password, cookies):
|
|
DATA = {
|
|
'location': '/',
|
|
'username': username,
|
|
'password': password,
|
|
'submit_login': ''
|
|
}
|
|
return requests.post(f'https://{SDAROT_DOMAIN}/login', data=DATA, cookies=cookies)
|
|
|
|
|
|
def get_dictionary_series(cookies):
|
|
DATA = "srl=1"
|
|
return requests.get(f"https://www.{SDAROT_DOMAIN}/ajax/index?srl=1", cookies=cookies, data=DATA).json()
|
|
|
|
|
|
def get_sid(dictionary, series_name):
|
|
return list(filter(lambda obj: series_name in " ".join(list(obj.values())), dictionary))
|
|
|
|
|
|
def create_new_token(cookies, sid, season, ep):
|
|
DATA = {
|
|
'preWatch': 'true',
|
|
'SID': str(sid),
|
|
'season': str(season),
|
|
'ep': str(ep)
|
|
}
|
|
HEADERS = {
|
|
"referer": "https://sdarot.buzz/"
|
|
}
|
|
res = requests.post(f"https://{SDAROT_DOMAIN}/ajax/watch", data=DATA, cookies=cookies, headers=HEADERS)
|
|
return res.content.decode()
|
|
|
|
|
|
def get_video_url(cookies, token, sid, season, episode):
|
|
DATA = {
|
|
'watch': 'true',
|
|
'token': token,
|
|
'serie': sid,
|
|
'season': season,
|
|
'episode': episode,
|
|
'type': 'episode'
|
|
}
|
|
HEADERS = {
|
|
"referer": "https://sdarot.buzz/"
|
|
}
|
|
res = requests.post(f"https://{SDAROT_DOMAIN}/ajax/watch", cookies=cookies, data=DATA, headers=HEADERS)
|
|
print(res.content)
|
|
print(res.json())
|
|
return "https://" + res.json()["watch"]["480"]
|
|
|
|
|
|
def download_video(cookies, video_url, file_path):
|
|
response = requests.get(video_url, stream=True, cookies=cookies, timeout=5)
|
|
|
|
with open(file_path, "wb") as file:
|
|
for chunk in response.iter_content(chunk_size=8192):
|
|
file.write(chunk)
|
|
|
|
|
|
def main():
|
|
sdarot_cookies = get_sdarot_cookies()
|
|
print(login_to_sdarot_tv("idan92", "asdqwe123", sdarot_cookies).status_code)
|
|
series = get_dictionary_series(sdarot_cookies)
|
|
sid = get_sid(series, "איש משפחה")[0]["id"]
|
|
token = create_new_token(sdarot_cookies, sid, 1, 1)
|
|
print("Start 30 seconds...")
|
|
for x in range(30):
|
|
print(x)
|
|
time.sleep(1)
|
|
video_url = get_video_url(sdarot_cookies, token, sid, 1, 1)
|
|
download_video(sdarot_cookies, video_url, "example.mp4")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|