Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import argparse
- import os
- import requests
- import time
- from datetime import datetime
- def _get_stream_info(user):
- url = f'https://twitcasting.tv/streamserver.php?target={user}&mode=client'
- r = requests.get(url, headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0' })
- data = r.json()
- return data
- def check_live_status(user):
- data = _get_stream_info(user)
- return data['movie']['live']
- if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='TwitCasting live stream monitor.')
- parser.add_argument('user_id', help='The user id to record. i.e. the string after "https://twitcasting.tv/" in URL')
- args = parser.parse_args()
- while True:
- live_status = check_live_status(args.user_id)
- if live_status == False:
- print(f'User {args.user_id} is offline, retrying every 15 seconds...')
- while live_status == False:
- time.sleep(15)
- live_status = check_live_status(args.user_id)
- t = datetime.now().strftime('%Y%m%d%H%M%S')
- os.system(f'yt-dlp http://twitcasting.tv/{args.user_id} --no-part -o "%(uploader_id)s/[%(id)s] %(title)s-{t}.ts"')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement