diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b694934 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv \ No newline at end of file diff --git a/test.py b/test.py new file mode 100644 index 0000000..750d363 --- /dev/null +++ b/test.py @@ -0,0 +1,57 @@ +import requests + + +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 = f"location=%2Findex&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 = f"preWatch=true&SID={sid}&season={season}&ep={ep}" + return requests.get(f"https://{SDAROT_DOMAIN}/ajax/watch", data=DATA, cookies=cookies).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" + return requests.get(f"https://{SDAROT_DOMAIN}/ajax/watch", cookies=cookies, data=DATA).json() + + +def download_video(): + COOKIES = { + "Sdarot": "gcgwRxWduRJnj8TxmSNL%2CDWw-skr22IYHTezvqfjT6pLLkfo1E6zy8s1VyKq6Ec8PRfvQNs5Sz0b37S%2CJXwi4LMjzyB8Lj1hf4FfSyu9bgKvGOnIFpTa8WtJQCm3%2CPks" + + } + file_path = "example.mp4" + response = requests.get("https://specter.sdarot.buzz/w/SD/480/3842/232888/232888.mp4?token=1Def_9N7EuYPezBVTs404w&time=1688228206&uid=640118", 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)) + series = get_dictionary_series(sdarot_cookies) + print(get_sid(series, "אלי כהן")) + + +if __name__ == '__main__': + main() +