add 'referer' to headers
This commit is contained in:
55
test.py
55
test.py
@@ -9,21 +9,14 @@ def get_sdarot_cookies():
|
||||
|
||||
|
||||
|
||||
def login_to_sdarot_tv(username, password, cookies): ## DOESN'T Work
|
||||
def login_to_sdarot_tv(username, password, cookies):
|
||||
DATA = {
|
||||
'location': '/index',
|
||||
'location': '/',
|
||||
'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)
|
||||
return requests.post(f'https://{SDAROT_DOMAIN}/login', data=DATA, cookies=cookies)
|
||||
|
||||
|
||||
def get_dictionary_series(cookies):
|
||||
@@ -36,16 +29,32 @@ def get_sid(dictionary, series_name):
|
||||
|
||||
|
||||
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)
|
||||
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 = 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)
|
||||
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"]
|
||||
@@ -64,15 +73,13 @@ def main():
|
||||
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")
|
||||
print("Start 30 seconds...")
|
||||
for x in range(32):
|
||||
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__':
|
||||
|
||||
Reference in New Issue
Block a user