Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import aiohttp
- import aiofiles
- @service
- @time_trigger
- def run_on_startup_or_reload():
- input_text.php_session_id.set_value('')
- @service
- @time_trigger('period(now + 5sec, 18sec)')
- def playa_las_vistas():
- URL = 'https://www.skylinewebcams.com/en/webcam/espana/canarias/santa-cruz-de-tenerife/playa-las-vistas.html'
- FILENAME = 'playa-las-vistas.m3u8'
- PATH = './www/images/webcams/'
- HEADERS = {
- 'authority': 'hd-auth.skylinewebcams.com',
- 'origin': 'https://www.skylinewebcams.com',
- 'referer': 'https://www.skylinewebcams.com/',
- 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
- }
- php_session_id = input_text.php_session_id
- async with aiohttp.ClientSession(cookie_jar = aiohttp.CookieJar()) as s:
- if php_session_id == '':
- async with s.get(URL, headers = HEADERS) as r:
- cookies = s.cookie_jar.filter_cookies('https://www.skylinewebcams.com').items()
- for key, cookie in cookies:
- if str(cookie.key) == 'PHPSESSID':
- php_session_id = cookie.value
- input_text.php_session_id.set_value(php_session_id)
- URL = 'https://hd-auth.skylinewebcams.com/live.m3u8?a=' + php_session_id
- async with s.get(URL, headers = HEADERS) as r:
- content = r.read()
- async with aiofiles.open(PATH + FILENAME, 'wb') as f:
- await f.write(content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement