From 21ef6202fd29cf2a108573f66519e79b814d449c Mon Sep 17 00:00:00 2001 From: horacio9a Date: Sun, 10 Dec 2017 11:38:50 +0100 Subject: [PATCH] v.1.0.7 Cam4 Remote 24/7 Anonymous RTMP Recorder --- c4rr.py | 101 +++++++++++++++++++++++++------------------------------- 1 file changed, 45 insertions(+), 56 deletions(-) diff --git a/c4rr.py b/c4rr.py index ef6fa62..821ce82 100644 --- a/c4rr.py +++ b/c4rr.py @@ -1,4 +1,4 @@ -# Cam4 Remote Anonymous RTMP Recorder v.1.0.6 by horacio9a for Python 2.7.13 +# Cam4 Remote Anonymous RTMP 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() @@ -24,10 +24,24 @@ url ='https://www.cam4.com/{}'.format(model) user_agent = {'user-agent': 'Mozilla/5.0 (Android; Mobile; rv:14.0) ..'} http = urllib3.PoolManager(10, headers=user_agent) r = http.urlopen('GET',url) -dec = (r.data) -#dec=urllib.unquote(enc).decode() +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 - - 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') - 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"{}"'.format(rtmp,vau,swf,vpu,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] + print (colored(' => App URL => {} <=', 'yellow', 'on_blue')).format(vau) + print + if len(vau) > 30: + print(colored(" => TRY AGAIN <=", 'yellow','on_blue')) + sys.exit() else: - print(colored(" => Model is OFFLINE <=", 'yellow','on_red')) - print - print(colored(" => END <=", 'yellow','on_blue')) - sys.exit() + pass -else: - print(colored(" => Page Not Found <=", 'yellow','on_red')) + if len(vau) > 1: + vpu0 = dec.split('videoPlayUrl":"')[1] + vpu = vpu0.split('"')[0] + rname = vpu.split('-')[0] + print (colored(' => Play URL => {} <=', 'yellow', 'on_blue')).format(vpu) print + + swf0 = dec.split('playerUrl":"')[1] + swf = swf0.split('"')[0] + + timestamp = str(time.strftime("%d%m%Y-%H%M%S")) + path = config.get('folders', 'output_folder') + filename = rname + '_C4_' + timestamp + rtmp = config.get('files', 'rtmpdump') + 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"{}"'.format(rtmp,vau,swf,vpu,pf) + os.system(command) print(colored(" => END <=", 'yellow','on_blue')) sys.exit()