From 054eec1146a49c0fd50bef5a06a5c48249ce074e Mon Sep 17 00:00:00 2001 From: horacio9a Date: Sun, 10 Dec 2017 11:36:33 +0100 Subject: [PATCH] v.1.0.7 Cam4 Anonymous All Modes Recorder --- c4a.py | 228 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 116 insertions(+), 112 deletions(-) diff --git a/c4a.py b/c4a.py index 2a09dc6..171d96f 100644 --- a/c4a.py +++ b/c4a.py @@ -1,4 +1,4 @@ -# Cam4 Anonymous All Modes Recorder v.1.0.6 by horacio9a for Python 2.7.13 +# Cam4 Anonymous All Modes Recorder v.1.0.7 by horacio9a for Python 2.7.13 import sys, os, urllib, urllib3, ssl, re, time, datetime, command urllib3.disable_warnings() @@ -40,7 +40,21 @@ r = http.urlopen('GET',url) enc = (r.data) dec=urllib.unquote(enc).decode() -if "Trending Cams" not in dec: +state0 = dec.split("showState: '")[1] +state = state0.split("'")[0] + +if len(state) == 0: + print(colored(" => Model is OFFLINE or wrong name<=", 'yellow','on_blue')) + print + print(colored(" => END <=", 'yellow','on_blue')) + sys.exit() +else: + pass + +print (colored(' => Model State => {} <=', 'white', 'on_green')).format(state) +print + +if len(state) > 0: try: age0 = dec.split('Age: Age:{} * Location:{} * Status:{} * Job:{} <=', 'yellow', 'on_blue')).format(age,loc,sta,occ) print - if "rtmp:" in dec: - vau0 = dec.split('rtmp://')[1] - vau = vau0.split('/')[0] - - if len(vau) > 30: - print(colored(" => TRY AGAIN <=", 'yellow','on_blue')) - sys.exit() - else: - pass - - if len(vau) > 1: - hlsurl0 = dec.split("hlsUrl: '")[1] - hlsurl = hlsurl0.split("'")[0] - - vpu0 = dec.split('videoPlayUrl":"')[1] - vpu = vpu0.split('"')[0] - - model0 = vpu.split('-')[0] - - swf0 = dec.split('playerUrl":"')[1] - swf = swf0.split('"')[0] - - print (colored(' => App URL => {} <=', 'yellow', 'on_blue')).format(vau) - print - print (colored(' => Play URL => {} <=', 'yellow', 'on_blue')).format(vpu) - print - - while True: - try: - mode = int(raw_input(colored(" => Mode => SL(4) FFMPEG(3) FFPLAY(2) YTDL(1) RTMP(0) => ", "yellow", "on_blue"))) - print - break - except ValueError: - print(colored("\n => Input must be a number <=", "yellow", "on_red")) - if mode == 0: - mod = 'RTMP' - if mode == 1: - mod = 'YTDL' - if mode == 2: - mod = 'FFPLAY' - if mode == 3: - mod = 'FFMPEG' - if mode == 4: - mod = 'SL' - - timestamp = str(time.strftime("%d%m%Y-%H%M%S")) - stime = str(time.strftime("%H:%M:%S")) - path = config.get('folders', 'output_folder') - filename = model0 + '_C4_' + timestamp - rtmp = config.get('files', 'rtmpdump') - ffplay = config.get('files', 'ffplay') - ffmpeg = config.get('files', 'ffmpeg') - youtube = config.get('files', 'youtube') - streamlink = config.get('files', 'streamlink') - - if mod == 'RTMP': - fn = filename + '.flv' - pf = (path + fn) - print (colored(' => RTMP-REC => {} <=', 'yellow', 'on_red')).format(fn) - print - command = '{} -r"rtmp://{}/cam4-edge-live" -a"cam4-edge-live" -W"{}" --live -y"{}" -o"{}" -q'.format(rtmp,vau,swf,vpu,pf) - os.system(command) - print(colored(" => END <=", 'yellow','on_blue')) - sys.exit() - - if mod == 'YTDL': - fn = filename + '.ts' - pf = (path + fn) - print (colored(" => YTDL-REC => {} <=", "yellow", "on_red")).format(fn) - print - command = ('{} -i --hls-use-mpegts --no-part -q {} -o {}'.format(youtube,hlsurl,pf)) - os.system(command) - print(colored(" => END <=", "yellow","on_blue")) - sys.exit() - - if mod == 'FFPLAY': - print (colored(" => FFPLAY => {} <=", "yellow", "on_red")).format(filename) - command = ('{} -loglevel panic -i "{}" -infbuf -autoexit -window_title "{} * {} * {} * {}"'.format(ffplay,hlsurl,model,loc,stime,mn)) - os.system(command) - print(colored(" => END <=", "yellow","on_blue")) - sys.exit() - - if mod == 'FFMPEG': - fn = filename + '.flv' - pf = (path + fn) - print (colored(' => FFMPEG-REC => {} <=', 'yellow', 'on_red')).format(fn) - print - command = ('{} -loglevel panic -i "{}" -c:v copy -c:a aac -b:a 160k "{}"'.format(ffmpeg,hlsurl,pf)) - os.system(command) - print(colored(" => END <=", 'yellow','on_blue')) - sys.exit() - - if mod == 'SL': - fn = filename + '.mp4' - pf = (path + fn) - print (colored(' => SL-REC >>> {} <<<', 'yellow', 'on_red')).format(fn) - print - command = ('{} hls://"{}" best -Q -o "{}"'.format(streamlink,hlsurl,pf)) - os.system(command) - print(colored(" => END <=", 'yellow','on_blue')) - sys.exit() - - else: - print(colored(" => Model in PRIVATE or AWAY ", 'yellow','on_red')) - print - print(colored(" => END <=", 'yellow','on_blue')) - sys.exit() + vau0 = dec.split('rtmp://')[1] + vau = vau0.split('/')[0] + if len(vau) > 30: + print(colored(" => TRY AGAIN <=", 'yellow','on_blue')) + sys.exit() else: - print(colored(" => Model is OFFLINE <=", 'yellow','on_red')) + pass + + if len(vau) > 1: + vpu0 = dec.split('videoPlayUrl":"')[1] + vpu = vpu0.split('"')[0] + + rname = vpu.split('-')[0] + lwcdn = vpu.split('-')[1] + + hlsurl0 = dec.split("hlsUrl: '")[1] + hlsurl = hlsurl0.split("'")[0] + purl0 = hlsurl.split('live/')[1] + purl = purl0.split('/')[0] + hlsurl1 = 'https://lwcdn-{}.cam4.com/cam4-origin-live/ngrp:{}_all/playlist.m3u8'.format(lwcdn,vpu) + hlsurl2 = 'https://lwcdn-{}.cam4.com/cam4-origin-live/amlst:{}_aac/playlist.m3u8'.format(lwcdn,vpu) + hlsurl3 = 'https://lwcdn-{}.cam4.com/cam4-origin-live/{}_aac/playlist.m3u8'.format(lwcdn,vpu) + print (colored(' => Play URL => {} <=', 'yellow', 'on_blue')).format(purl) print + + swf0 = dec.split('playerUrl":"')[1] + swf = swf0.split('"')[0] + + while True: + try: + mode = int(raw_input(colored(" => Mode => EXIT(5) SL(4) FFMPEG(3) FFPLAY(2) YTDL(1) RTMP(0) => ", "yellow", "on_blue"))) + print + break + except ValueError: + print(colored("\n => Input must be a number <=", "yellow", "on_red")) + if mode == 0: + mod = 'RTMP' + if mode == 1: + mod = 'YTDL' + if mode == 2: + mod = 'FFPLAY' + if mode == 3: + mod = 'FFMPEG' + if mode == 4: + mod = 'SL' + if mode == 5: + mod = 'EXIT' + +timestamp = str(time.strftime("%d%m%Y-%H%M%S")) +stime = str(time.strftime("%H:%M:%S")) +path = config.get('folders', 'output_folder') +filename = rname + '_C4_' + timestamp +rtmp = config.get('files', 'rtmpdump') +ffplay = config.get('files', 'ffplay') +ffmpeg = config.get('files', 'ffmpeg') +youtube = config.get('files', 'youtube') +streamlink = config.get('files', 'streamlink') + +if mod == 'RTMP': + fn = filename + '.flv' + pf = (path + fn) + print (colored(' => RTMP-REC => {} <=', 'yellow', 'on_red')).format(fn) + print + command = '{} -r"rtmp://{}/cam4-edge-live" -a"cam4-edge-live" -W"{}" --live -y"{}" -o"{}" -q'.format(rtmp,vau,swf,vpu,pf) + os.system(command) print(colored(" => END <=", 'yellow','on_blue')) sys.exit() -else: - print(colored(" => Page Not Found <=", 'yellow','on_red')) +if mod == 'YTDL': + fn = filename + '.ts' + pf = (path + fn) + print (colored(" => YTDL-REC => {} <=", "yellow", "on_red")).format(fn) print + command = ('{} -i --hls-use-mpegts --no-part -q {} -o {}'.format(youtube,hlsurl,pf)) + os.system(command) + print(colored(" => END <=", "yellow","on_blue")) + sys.exit() + +if mod == 'FFPLAY': + print (colored(" => FFPLAY => {} <=", "yellow", "on_magenta")).format(filename) + command = ('{} -loglevel panic -i "{}" -infbuf -autoexit -window_title "{} * {} * {} * {}"'.format(ffplay,hlsurl,rname,loc,stime,mn)) + os.system(command) + print(colored(" => END <=", "yellow","on_blue")) + sys.exit() + +if mod == 'FFMPEG': + fn = filename + '.flv' + pf = (path + fn) + print (colored(' => FFMPEG-REC => {} <=', 'yellow', 'on_red')).format(fn) + print + command = ('{} -hide_banner -loglevel panic -i "{}" -c:v copy -c:a aac -b:a 160k "{}"'.format(ffmpeg,hlsurl,pf)) + os.system(command) + print(colored(" => END <=", 'yellow','on_blue')) + sys.exit() + +if mod == 'SL': + fn = filename + '.mp4' + pf = (path + fn) + print (colored(' => SL-REC >>> {} <<<', 'yellow', 'on_red')).format(fn) + print + command = ('{} hls://"{}" best -Q -o "{}"'.format(streamlink,hlsurl,pf)) + os.system(command) + print(colored(" => END <=", 'yellow','on_blue')) + sys.exit() + +if mod == 'EXIT': print(colored(" => END <=", 'yellow','on_blue')) sys.exit()