v.2.1.0 Cam4 Anonymous All Modes Recorder for Python3.12

This commit is contained in:
horacio9a 2024-03-18 10:14:52 +01:00 committed by GitHub
parent 8ea828e6c9
commit d0ae2a80db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

460
c43.py
View file

@ -1,7 +1,7 @@
# Cam4 Anonymous All Modes Recorder v.2.0.2 by horacio9a for Python 3.9.1 # Cam4 FFMPEG/STREAMLINK/YTDL Anonymous All Modes Recorder v.2.1.0 by horacio9a for Python 3.12.2
# coding: utf-8 # coding: utf-8
import sys, os, urllib, urllib3, ssl, re, time, datetime, requests, random, command, livestreamer, streamlink import sys, os, urllib, urllib3, ssl, re, time, datetime, requests, command, streamlink
urllib3.disable_warnings() urllib3.disable_warnings()
from urllib3 import PoolManager from urllib3 import PoolManager
from urllib.parse import quote from urllib.parse import quote
@ -11,6 +11,7 @@ from termcolor import colored
import configparser import configparser
Config = configparser.ConfigParser() Config = configparser.ConfigParser()
Config.read('config3.ini') Config.read('config3.ini')
country_domain = Config.get('settings', 'country_domain')
init() init()
print() print()
@ -81,34 +82,68 @@ if mod == 'C4OW':
if mod == 'C4OA': if mod == 'C4OA':
while True: while True:
try: try:
c4oa = int(input(colored(' => Select => <500(0) <1000(1) <1500(2) <2000(3) <2500(4) <3000(5) <3500(6) => ', 'white', 'on_blue'))) c4oa = int(input(colored(' => Select => <250(0) <500(1) <750(2) <1000(3) <1250(4) <1500(5) <1750(6) <2000(7) <2250(8) <2500(9) <2750(10) <3000(11) => ', 'white', 'on_blue')))
print() print()
break break
except ValueError: except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red')) print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
if c4oa > 6: if c4oa > 11:
sys.exit() sys.exit()
if c4oa == 0: if c4oa == 0:
oa = 'OA500' oa = 'OA250'
if c4oa == 1: if c4oa == 1:
oa = 'OA1000' oa = 'OA500'
if c4oa == 2: if c4oa == 2:
oa = 'OA1500' oa = 'OA750'
if c4oa == 3: if c4oa == 3:
oa = 'OA2000' oa = 'OA1000'
if c4oa == 4: if c4oa == 4:
oa = 'OA2500' oa = 'OA1250'
if c4oa == 5: if c4oa == 5:
oa = 'OA3000' oa = 'OA1500'
if c4oa == 6: if c4oa == 6:
oa = 'OA3500' oa = 'OA1750'
if c4oa == 7:
oa = 'OA2000'
if c4oa == 8:
oa = 'OA2250'
if c4oa == 9:
oa = 'OA2500'
if c4oa == 10:
oa = 'OA2750'
if c4oa == 11:
oa = 'OA3000'
if oa == 'OA250':
while True:
try:
modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (250, 3000):
break
print(' =>',(num+1),value[:-1])
print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print()
nr_lines = sum(1 for line in open(Config.get('files', 'online_all_model_list')))
if mn > nr_lines:
print(colored(' => Too big number <=', 'white', 'on_red'))
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
model = open(Config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print()
if oa == 'OA500': if oa == 'OA500':
while True: while True:
try: try:
modellist = open(Config.get('files', 'online_all_model_list'),'r') modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist): for (num, value) in enumerate(modellist):
if num in range (500, 5000): if num in range (500, 3000):
break break
print(' =>',(num+1),value[:-1]) print(' =>',(num+1),value[:-1])
print() print()
@ -127,14 +162,62 @@ if mod == 'C4OA':
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model)) print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print() print()
if oa == 'OA750':
while True:
try:
modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (750, 3000):
break
print(' =>',(num+1),value[:-1])
print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print()
nr_lines = sum(1 for line in open(Config.get('files', 'online_all_model_list')))
if mn > nr_lines:
print(colored(' => Too big number <=', 'white', 'on_red'))
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
model = open(Config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print()
if oa == 'OA1000': if oa == 'OA1000':
while True: while True:
try: try:
modellist = open(Config.get('files', 'online_all_model_list'),'r') modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist): for (num, value) in enumerate(modellist):
if num in range (1000, 5000): if num in range (1000, 3000):
break break
print(' =>',(num+1),value[:-1]) print(' =>',(num+1),value[:-1])
print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print()
nr_lines = sum(1 for line in open(Config.get('files', 'online_all_model_list')))
if mn > nr_lines:
print(colored(' => Too big number <=', 'white', 'on_red'))
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
model = open(Config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print()
if oa == 'OA1250':
while True:
try:
modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (1250, 3000):
break
print(' =>',(num+1),value[:-1])
print() print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue'))) mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print() print()
@ -156,9 +239,9 @@ if mod == 'C4OA':
try: try:
modellist = open(Config.get('files', 'online_all_model_list'),'r') modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist): for (num, value) in enumerate(modellist):
if num in range (1500, 5000): if num in range (1500, 3000):
break break
print(' =>',(num+1),value[:-1]) print(' =>',(num+1),value[:-1])
print() print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue'))) mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print() print()
@ -175,14 +258,56 @@ if mod == 'C4OA':
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model)) print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print() print()
if oa == 'OA1750':
while True:
try:
modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (1750, 3000):
break
print(' =>',(num+1),value[:-1])
print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
model = open(Config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print()
if oa == 'OA2000': if oa == 'OA2000':
while True: while True:
try: try:
modellist = open(Config.get('files', 'online_all_model_list'),'r') modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist): for (num, value) in enumerate(modellist):
if num in range (2000, 5000): if num in range (2000, 3000):
break break
print(' =>',(num+1),value[:-1]) print(' =>',(num+1),value[:-1])
print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print()
nr_lines = sum(1 for line in open(Config.get('files', 'online_all_model_list')))
if mn > nr_lines:
print(colored(' => Too big number <=', 'white', 'on_red'))
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
model = open(Config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print()
if oa == 'OA2250':
while True:
try:
modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (2250, 3000):
break
print(' =>',(num+1),value[:-1])
print() print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue'))) mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print() print()
@ -204,9 +329,33 @@ if mod == 'C4OA':
try: try:
modellist = open(Config.get('files', 'online_all_model_list'),'r') modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist): for (num, value) in enumerate(modellist):
if num in range (2500, 5000): if num in range (2500, 3000):
break break
print(' =>',(num+1),value[:-1]) print(' =>',(num+1),value[:-1])
print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print()
nr_lines = sum(1 for line in open(Config.get('files', 'online_all_model_list')))
if mn > nr_lines:
print(colored(' => Too big number <=', 'white', 'on_red'))
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
model = open(Config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print()
if oa == 'OA2750':
while True:
try:
modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (2750, 3000):
break
print(' =>',(num+1),value[:-1])
print() print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue'))) mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print() print()
@ -228,9 +377,9 @@ if mod == 'C4OA':
try: try:
modellist = open(Config.get('files', 'online_all_model_list'),'r') modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist): for (num, value) in enumerate(modellist):
if num in range (3000, 5000): if num in range (3000, 3000):
break break
print(' =>',(num+1),value[:-1]) print(' =>',(num+1),value[:-1])
print() print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue'))) mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print() print()
@ -247,168 +396,125 @@ if mod == 'C4OA':
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model)) print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print() print()
if oa == 'OA3500': url ='https://{}.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(country_domain, model)
while True:
try:
modellist = open(Config.get('files', 'online_all_model_list'),'r')
for (num, value) in enumerate(modellist):
if num in range (3500, 5000):
break
print(' =>',(num+1),value[:-1])
print()
mn = int(input(colored(' => Select C4 Online All Models => ', 'white', 'on_blue')))
print()
break
except ValueError:
print(colored('\n => Input must be a number <=\n', 'white', 'on_red'))
model = open(Config.get('files', 'online_all_model_list'), 'r').readlines()[mn-1][:-1]
print ((colored(' => Selected C4 Online All Model => {} <=', 'white', 'on_blue')).format(model))
print()
url ='https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(model)
manager = PoolManager(10) manager = PoolManager(10)
r = manager.request('GET', url) r = manager.request('GET', url)
enc = quote(r.data) enc = quote(r.data)
dec= unquote(enc) dec= unquote(enc)
if 'canUseCDN":true' in dec: if len(dec) > 0:
hlsurl0 = dec.split('cdnURL":"')[1] hlsur2 = dec.split('cdnURL":"')[1]
hlsurl = hlsurl0.split('"')[0] hlsurl = hlsur2.split('"')[0]
if len(hlsurl) > 0: print ((colored(' => HlsUrl => {} <=', 'white', 'on_magenta')).format(hlsurl))
try: print ()
streamName0 = dec.split('streamName":"')[1] try:
streamName = streamName0.split('-')[0] mode = int(input(colored(' => Mode => Exit(5) - URL(4) - YTDL(3) - SL(2) - FFMPEG(1) - PLAYER(0) => ', 'white', 'on_green')))
except: except ValueError:
sys.exit() print()
print(colored(' => Input must be a number <=', 'white', 'on_red'))
if mode > 5:
print()
print(colored(' => Too big number <=', 'white', 'on_red'))
mod = 'EXIT'
if mode == 0:
mod = 'PLAYER'
if mode == 1:
mod = 'FFMPEG'
if mode == 2:
mod = 'SL'
if mode == 3:
mod = 'YTDL'
if mode == 4:
mod = 'URL'
if mode == 5:
mod = 'EXIT'
while True: timestamp = str(time.strftime('%d%m%Y-%H%M%S'))
try: path = Config.get('folders', 'output_folder')
mode = int(input(colored(' => Mode => Exit(6) - URL(5) - YTDL(4) - LS(3) - SL(2) - FFMPEG(1) - PLAYER(0) => ', 'white', 'on_green'))) fn = model + '_C4_' + timestamp
break fn1 = model + '_C4_' + timestamp + '.flv'
except ValueError: fn2 = model + '_C4_' + timestamp + '.mp4'
print() fn3 = model + '_C4_' + timestamp + '.ts'
print(colored(' => Input must be a number <=', 'white', 'on_red')) fn4 = model + '_C4_' + timestamp + '.txt'
if mode > 6: pf1 = (path + fn1)
print() pf2 = (path + fn2)
print(colored(' => Too big number <=', 'white', 'on_red')) pf3 = (path + fn3)
mod = 'EXIT' pf4 = (path + fn4)
if mode == 0: player = Config.get('files', 'player')
mod = 'PLAYER' ffmpeg = Config.get('files', 'ffmpeg')
if mode == 1: youtube = Config.get('files', 'youtube')
mod = 'FFMPEG' streamlink = Config.get('files', 'streamlink')
if mode == 2:
mod = 'SL'
if mode == 3:
mod = 'LS'
if mode == 4:
mod = 'YTDL'
if mode == 5:
mod = 'URL'
if mode == 6:
mod = 'EXIT'
timestamp = str(time.strftime('%d%m%Y-%H%M%S')) if mod == 'PLAYER':
stime = str(time.strftime('%H:%M:%S')) print()
path = Config.get('folders', 'output_folder') print ((colored(' => PLAYER => {} <=', 'white', 'on_magenta')).format(fn))
fn = streamName + '_C4_' + timestamp print()
fn1 = streamName + '_C4_' + timestamp + '.flv' command = ('{} -p {} {} best'.format(streamlink, player, hlsurl))
fn2 = streamName + '_C4_' + timestamp + '.mp4' os.system(command)
fn3 = streamName + '_C4_' + timestamp + '.ts' while True:
fn4 = streamName + '_C4_' + timestamp + '.txt' try:
pf1 = (path + fn1) print()
pf2 = (path + fn2) prog = int(input(colored(' => Mode => URL(4) - YTDL(3) - SL(2) - FFMPEG(1) - Exit(0) => ', 'white', 'on_green')))
pf3 = (path + fn3) break
pf4 = (path + fn4) except ValueError:
player = Config.get('files', 'player') print()
ffmpeg = Config.get('files', 'ffmpeg') print(colored(' => Input must be a number <=', 'white', 'on_red'))
youtube = Config.get('files', 'youtube') print()
streamlink = Config.get('files', 'streamlink') if prog > 4:
livestreamer = Config.get('files', 'livestreamer') print()
print(colored(' => Too big number <=', 'white', 'on_red'))
mod = 'EXIT'
if prog == 0:
mod = 'EXIT'
if prog == 1:
mod = 'FFMPEG'
if prog == 2:
mod = 'SL'
if prog == 3:
mod = 'YTDL'
if prog == 4:
mod = 'URL'
if mod == 'PLAYER': if mod == 'FFMPEG':
print() print()
print ((colored(' => PLAYER => {} <=', 'white', 'on_magenta')).format(fn)) print ((colored(' => FFMPEG-REC => {} <=', 'white', 'on_red')).format(pf1))
print() command = '{} -hide_banner -loglevel panic -i {} -c:v copy -c:a aac -b:a 128k {}'.format(ffmpeg,hlsurl,pf1)
command = ('{} -p {} {} best'.format(streamlink, player, hlsurl)) os.system(command)
os.system(command) sys.exit()
while True:
try:
print()
prog = int(input(colored(' => Mode => URL(5) - YTDL(4) - LS(3) - SL(2) - FFMPEG(1) - Exit(0) => ', 'white', 'on_green')))
break
except ValueError:
print()
print(colored(' => Input must be a number <=', 'white', 'on_red'))
if prog > 5:
print()
print(colored(' => Too big number <=', 'white', 'on_red'))
mod = 'EXIT'
if prog == 0:
mod = 'EXIT'
if prog == 1:
mod = 'FFMPEG'
if prog == 2:
mod = 'SL'
if prog == 3:
mod = 'LS'
if prog == 4:
mod = 'YTDL'
if prog == 5:
mod = 'URL'
if mod == 'FFMPEG': if mod == 'SL':
print() print()
print ((colored(' => FFMPEG-REC => {} <=', 'white', 'on_red')).format(fn1)) print ((colored(' => SL-REC => {} Size ( Time @ Speed ) <=', 'white', 'on_red')).format(pf2))
command = ('{} -hide_banner -loglevel panic -i {} -c:v copy -c:a aac -b:a 128k {}'.format(ffmpeg,hlsurl,pf1)) print()
os.system(command) 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,pf2))
sys.exit() os.system(command)
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
if mod == 'SL': if mod == 'YTDL':
print() print()
print ((colored(' => SL-REC => {} ( Size @ Speed ) <=', 'white', 'on_red')).format(fn2)) print ((colored(' => YTDL-REC => {} <=', 'white', 'on_red')).format(pf3))
print() command = ('{} -i --geo-bypass --hls-use-mpegts --no-part -q --no-warnings --no-check-certificate {} -o {}'.format(youtube,hlsurl,pf3))
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,pf2)) os.system(command)
os.system(command) print()
print() print(colored(' => END <= ', 'white','on_blue'))
print(colored(' => END <= ', 'white','on_blue')) sys.exit()
sys.exit()
if mod == 'LS': if mod == 'URL':
print() print()
print ((colored(' => LS-REC => {} ( Size @ Speed ) <=', 'white', 'on_red')).format(fn2)) print((colored(' => URL => {} <=', 'white', 'on_red')).format(pf4))
print() file=open(pf4,'w')
command = ('{} hlsvariant://{} best -Q -o {}'.format(livestreamer,hlsurl,pf2)) file.write(hlsurl)
os.system(command) file.close()
print() print()
print(colored(' => END <= ', 'white','on_blue')) print(colored(' => END <=', 'white','on_blue'))
sys.exit() sys.exit()
if mod == 'YTDL': if mod == 'EXIT':
print() print()
print ((colored(' => YTDL-REC => {} <=', 'white', 'on_red')).format(fn3)) print(colored(' => END <=', 'white','on_blue'))
command = ('{} -i --geo-bypass --hls-use-mpegts --no-part -q --no-warnings --no-check-certificate {} -o {}'.format(youtube,hlsurl,pf3)) sys.exit()
os.system(command)
print()
print(colored(' => END <= ', 'white','on_blue'))
sys.exit()
if mod == 'URL':
print()
print((colored(' => URL => {} <=', 'white', 'on_green')).format(fn4))
file=open(pf4,'w')
file.write(hlsurl)
file.close()
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
if mod == 'EXIT':
print()
print(colored(' => END <=', 'white','on_blue'))
sys.exit()
else:
sys.exit()
else: else:
print(colored(' => Model is offline or wrong name <=', 'white','on_red')) print(colored(' => Model is offline or wrong name <=', 'white','on_red'))