From 84189691ec6713c333b7147ba5f774f6c3912d17 Mon Sep 17 00:00:00 2001 From: horacio9a Date: Sat, 22 May 2021 16:50:37 +0200 Subject: [PATCH] v.2.0.0 Cam4 Remote 24/7 Anonymous STREAMLINK Recorder for Python39 --- c4slr3.py | 131 ++++++++++++------------------------------------------ 1 file changed, 29 insertions(+), 102 deletions(-) diff --git a/c4slr3.py b/c4slr3.py index b09465b..f5bef82 100644 --- a/c4slr3.py +++ b/c4slr3.py @@ -1,4 +1,4 @@ -# Cam4 Remote Anonymous STREAMLINK Recorder v.1.1.1 by horacio9a for Python 3.9.1 +# Cam4 Remote Anonymous STREAMLINK Recorder v.2.0.0 by horacio9a for Python 3.9.1 # coding: utf-8 import sys, os, urllib, urllib3, ssl, re, time, datetime, command @@ -9,124 +9,51 @@ from urllib.parse import unquote from colorama import init, Fore, Back, Style from termcolor import colored import configparser -config = configparser.ConfigParser() -config.read('config.ini') +Config = configparser.ConfigParser() +Config.read('config.ini') init() print() print(colored(' => START <=', 'white', 'on_blue')) +print() if __name__=='__main__': import sys model = sys.argv[1] -url ='https://www.cam4.com/{}'.format(model) +url ='https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(model) manager = PoolManager(10) r = manager.request('GET', url) enc = quote(r.data) dec= unquote(enc) -if 'showState' in dec: - status0 = dec.split("showState: '")[1] - status = status0.split("'")[0] - if len(status) > 0: - try: - gender0 = dec.split(' gender-')[1] - gender1 = gender0.split('" t')[0] - gender = gender1.split('="')[1] - except: - gender = '-' +if 'canUseCDN":true' in dec: + hlsurl0 = dec.split('cdnURL":"')[1] + hlsurl = hlsurl0.split('"')[0] + if len(hlsurl) > 0: + try: + streamName0 = dec.split('streamName":"')[1] + streamName = streamName0.split('-')[0] + except: + sys.exit() - try: - orientation0 = dec.split('orientation ')[1] - orientation1 = orientation0.split('')[1] - except: - orientation = '-' + timestamp = str(time.strftime('%d%m%Y-%H%M%S')) + stime = str(time.strftime('%H:%M:%S')) + path = Config.get('folders', 'output_folder') + streamlink = Config.get('files', 'streamlink') + filename = streamName + '_C4_' + timestamp + '.mp4' + pf = path + filename + print ((colored(' => SL-REC => {} ( Size @ Speed )', 'white', 'on_red')).format(filename)) + print() + command = ('{} hls://{} best -Q --hls-live-edge 1 --hls-playlist-reload-attempts 9 --hls-segment-threads 3 --hls-segment-timeout 5.0 --hls-timeout 20.0 -o {}'.format(streamlink,hlsurl,pf)) + os.system(command) + sys.exit() - try: - country0 = dec.split('"country"')[1] - country1 = country0.split('" t')[0] - country = country1.split('t="')[1] - except: - country = '-' - - try: - age0 = dec.split('Age:')[1] - except: - age = '-' - - try: - loc0 = dec.split('Location:')[1] - loc3 = re.sub(',', '', loc2) - loc = re.sub(' ', '', loc3) - except: - loc = '-' - - try: - sta0 = dec.split('Status:')[1] - except: - sta = '-' - - try: - room0 = dec.split('room":"')[1] - room = room0.split('"')[0] - except: - room = '-' - - try: - ms0 = dec.split('Member since:')[1] - ms3 = re.sub(' ', '-', ms2) - ms = re.sub(',', '', ms3) - except: - ms = '-' - - try: - eth0 = dec.split('Ethnicity:')[1] - eth = re.sub(' ', '', eth2) - except: - eth = '-' - - vpu0 = dec.split('videoPlayUrl":"')[1] - vpu = vpu0.split('"')[0] - - wcdn = vpu.split('-')[1] - - hlsurl = 'https://cam4-hls.xcdnpro.com/{}/cam4-origin-live/{}_aac/playlist.m3u8'.format(wcdn,vpu) - - print ((colored('\n => Room: ({}) * Member since: ({}) * Room status: ({}) <=', 'white', 'on_blue')).format(room,ms,status)) - print ((colored('\n => Age: ({}) * Gender: ({}) * Orientation: ({}) * Status: ({}) <=', 'white', 'on_blue')).format(age,gender,orientation,sta)) - print ((colored('\n => Country: ({}) * Location: ({}) * Ethnic: ({}) <=', 'white', 'on_blue')).format(country,loc,eth)) - - timestamp = str(time.strftime('%d%m%Y-%H%M%S')) - path = config.get('folders', 'output_folder') - streamlink = config.get('files', 'streamlink') - filename = room + '_C4_' + timestamp + '.mp4' - pf = path + filename - print ((colored('\n => SL-REC >>> {} <<<', 'white', 'on_red')).format(filename)) - print() - command = ('{} hls://{} best -Q --hls-live-edge 1 --hls-playlist-reload-attempts 9 --hls-segment-threads 3 --hls-segment-timeout 5.0 --hls-timeout 20.0 -o {}'.format(streamlink,hlsurl,pf)) - os.system(command) - sys.exit() - - else: - print(colored('\n => Model is offline <=', 'white','on_red')) - print() - print(colored(' => END <=', 'white','on_blue')) - sys.exit() + else: + sys.exit() else: - print(colored('\n => Page Not Found <=', 'white','on_red')) + print(colored(' => Model is offline or wrong name <=', 'white','on_red')) print() print(colored(' => END <=', 'white','on_blue')) - sys.exit() \ No newline at end of file + sys.exit()