2024-03-18 17:19:49 +08:00
|
|
|
# Cam4 Remote Anonymous FFMPEG Recorder v.2.1.0 by horacio9a for Python 3.12.2
|
2021-04-22 17:48:01 +08:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
import sys, os, urllib, urllib3, ssl, re, time, datetime, command
|
|
|
|
urllib3.disable_warnings()
|
|
|
|
from urllib3 import PoolManager
|
|
|
|
from urllib.parse import quote
|
|
|
|
from urllib.parse import unquote
|
|
|
|
from colorama import init, Fore, Back, Style
|
|
|
|
from termcolor import colored
|
|
|
|
import configparser
|
2021-05-22 22:48:25 +08:00
|
|
|
Config = configparser.ConfigParser()
|
2021-05-26 05:27:52 +08:00
|
|
|
Config.read('config3.ini')
|
2024-03-18 17:19:49 +08:00
|
|
|
country_domain = Config.get('settings', 'country_domain')
|
2021-04-22 17:48:01 +08:00
|
|
|
|
|
|
|
init()
|
|
|
|
print()
|
|
|
|
print(colored(' => START <=', 'white', 'on_blue'))
|
2021-05-22 22:48:25 +08:00
|
|
|
print()
|
2021-04-22 17:48:01 +08:00
|
|
|
|
|
|
|
if __name__=='__main__':
|
|
|
|
import sys
|
|
|
|
model = sys.argv[1]
|
|
|
|
|
2024-03-18 17:19:49 +08:00
|
|
|
url ='https://{}.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(country_domain, model)
|
2021-04-22 17:48:01 +08:00
|
|
|
manager = PoolManager(10)
|
|
|
|
r = manager.request('GET', url)
|
|
|
|
enc = quote(r.data)
|
|
|
|
dec= unquote(enc)
|
|
|
|
|
2024-03-18 17:19:49 +08:00
|
|
|
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 = 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()
|
2021-05-23 07:26:51 +08:00
|
|
|
|
|
|
|
else:
|
|
|
|
print(colored(' => Model is offline or wrong name <=', 'white','on_red'))
|
|
|
|
print()
|
|
|
|
print(colored(' => END <=', 'white','on_blue'))
|
|
|
|
sys.exit()
|