81 lines
2.8 KiB
Python
81 lines
2.8 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): ## DOESN'T Work
|
|
DATA = {
|
|
'location': '/index',
|
|
'username': 'idan92',
|
|
'password': 'asdqwe123',
|
|
'submit_login': ''
|
|
}
|
|
print(cookies)
|
|
print(DATA)
|
|
COOKIES = {"Sdarot": "OXuQa5b8BPSKUDB%2CNlj8aGhqJGm5gC%2CvHP7SHvhFriFybKNf4noTOUhSDmGyMjVQ0YmnR1KVsN%2CaueQ54me7glMc5MDNqcezg-jbe8VpO-PFWV-sB%2CNgCSDeLv6iX7bs"}
|
|
headers = {
|
|
'cookie': 'Sdarot=OXuQa5b8BPSKUDB%2CNlj8aGhqJGm5gC%2CvHP7SHvhFriFybKNf4noTOUhSDmGyMjVQ0YmnR1KVsN%2CaueQ54me7glMc5MDNqcezg-jbe8VpO-PFWV-sB%2CNgCSDeLv6iX7bs'
|
|
}
|
|
return requests.get('https://www.sdarot.buzz/login', data=DATA, headers=headers)
|
|
# return requests.post(f'https://www.{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 = f"preWatch=true&SID={sid}&season={season}&ep={ep}"
|
|
res = requests.post(f"https://www.{SDAROT_DOMAIN}/ajax/watch", data=DATA, cookies=cookies)
|
|
print(res.status_code)
|
|
print(res.content)
|
|
return res.content.decode()
|
|
|
|
|
|
def get_video_url(cookies, token, sid, season, episode):
|
|
DATA = f"watch=true&token={token}&serie={sid}&season={season}&episode={episode}&type=episode"
|
|
res = requests.get(f"https://{SDAROT_DOMAIN}/ajax/watch", cookies=cookies, data=DATA)
|
|
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"]
|
|
print(sid)
|
|
token = create_new_token(sdarot_cookies, sid, 1, 1)
|
|
# print("Start 30 seconds...")
|
|
# print(sdarot_cookies)
|
|
# print(token)
|
|
# print(sid)
|
|
# time.sleep(32) # import time
|
|
# video_url = get_video_url(sdarot_cookies, token, sid, 1, 1)
|
|
# download_video(sdarot_cookies, video_url, "example.mp4")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|