v.2.1.0 Cam4 Remote 24/7 Anonymous FFMPEG Recorder for Python3.12

This commit is contained in:
horacio9a 2024-03-18 10:19:49 +01:00 committed by GitHub
parent 732814ea14
commit 7302985da9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
# Cam4 Remote Anonymous FFMPEG Recorder v.2.0.1 by horacio9a for Python 3.9.1
# Cam4 Remote Anonymous FFMPEG Recorder v.2.1.0 by horacio9a for Python 3.12.2
# coding: utf-8
import sys, os, urllib, urllib3, ssl, re, time, datetime, command
@ -11,6 +11,7 @@ from termcolor import colored
import configparser
Config = configparser.ConfigParser()
Config.read('config3.ini')
country_domain = Config.get('settings', 'country_domain')
init()
print()
@ -21,35 +22,26 @@ if __name__=='__main__':
import sys
model = sys.argv[1]
url ='https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(model)
url ='https://{}.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(country_domain, model)
manager = PoolManager(10)
r = manager.request('GET', url)
enc = quote(r.data)
dec= unquote(enc)
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()
if len(dec) > 0:
hlsur2 = dec.split('cdnURL":"')[1]
hlsurl = hlsur2.split('"')[0]
timestamp = str(time.strftime('%d%m%Y-%H%M%S'))
stime = str(time.strftime('%H:%M:%S'))
path = Config.get('folders', 'output_folder')
ffmpeg = Config.get('files', 'ffmpeg')
filename = streamName + '_C4_' + timestamp + '.flv'
pf = path + filename
print ((colored(' => FFMPEG-REC => {} <=', 'white', 'on_red')).format(filename))
command = ('{} -hide_banner -loglevel panic -i {} -c:v copy -c:a aac -b:a 128k {}'.format(ffmpeg,hlsurl,pf))
os.system(command)
sys.exit()
else:
sys.exit()
timestamp = str(time.strftime('%d%m%Y-%H%M%S'))
stime = str(time.strftime('%H:%M:%S'))
path = Config.get('folders', 'output_folder')
ffmpeg = Config.get('files', 'ffmpeg')
filename = model + '_C4_' + timestamp + '.flv'
pf = path + filename
print ((colored(' => FFMPEG-REC => {} <=', 'white', 'on_red')).format(pf))
command = '{} -hide_banner -loglevel panic -i {} -c:v copy -c:a aac -b:a 128k {}'.format(ffmpeg,hlsurl,filename)
os.system(command)
sys.exit()
else:
print(colored(' => Model is offline or wrong name <=', 'white','on_red'))