mirror of
https://github.com/horacio9a/cam4-anonymous.git
synced 2024-11-13 03:34:25 +08:00
v.2.1.0 Cam4 Remote 24/7 Anonymous STREAMLINK Recorder for Python2.7
This commit is contained in:
parent
f218d94edf
commit
7496e04f25
1 changed files with 17 additions and 25 deletions
42
c4slr.py
42
c4slr.py
|
@ -1,4 +1,4 @@
|
||||||
# Cam4 Remote Anonymous STREAMLINK Recorder v.2.0.1 by horacio9a for Python 2.7.18
|
# Cam4 Remote Anonymous STREAMLINK Recorder v.2.1.0 by horacio9a for Python 2.7.18
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import sys, os, urllib, urllib3, ssl, re, time, datetime, requests, random, command
|
import sys, os, urllib, urllib3, ssl, re, time, datetime, requests, random, command
|
||||||
|
@ -11,6 +11,7 @@ from termcolor import colored
|
||||||
import configparser
|
import configparser
|
||||||
Config = configparser.ConfigParser()
|
Config = configparser.ConfigParser()
|
||||||
Config.read('config.ini')
|
Config.read('config.ini')
|
||||||
|
country_domain = Config.get('settings', 'country_domain')
|
||||||
|
|
||||||
init()
|
init()
|
||||||
print
|
print
|
||||||
|
@ -21,36 +22,27 @@ if __name__=='__main__':
|
||||||
import sys
|
import sys
|
||||||
model = sys.argv[1]
|
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)
|
manager = PoolManager(10)
|
||||||
r = manager.request('GET', url)
|
r = manager.request('GET', url)
|
||||||
enc = (r.data)
|
enc = (r.data)
|
||||||
dec=urllib.unquote(enc)
|
dec=urllib.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:
|
|
||||||
try:
|
|
||||||
streamName0 = dec.split('streamName":"')[1]
|
|
||||||
streamName = streamName0.split('-')[0]
|
|
||||||
except:
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
timestamp = str(time.strftime('%d%m%Y-%H%M%S'))
|
timestamp = str(time.strftime('%d%m%Y-%H%M%S'))
|
||||||
stime = str(time.strftime('%H:%M:%S'))
|
stime = str(time.strftime('%H:%M:%S'))
|
||||||
path = Config.get('folders', 'output_folder')
|
path = Config.get('folders', 'output_folder')
|
||||||
streamlink = Config.get('files', 'streamlink')
|
streamlink = Config.get('files', 'streamlink')
|
||||||
filename = streamName + '_C4_' + timestamp + '.mp4'
|
filename = model + '_C4_' + timestamp + '.mp4'
|
||||||
pf = path + filename
|
pf = path + filename
|
||||||
print (colored(' => SL-REC => {} ( Size @ Speed )', 'white', 'on_red')).format(filename)
|
print (colored(' => SL-REC => {} ( Size @ Speed )', 'white', 'on_red')).format(filename)
|
||||||
print
|
print
|
||||||
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,pf))
|
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,pf))
|
||||||
os.system(command)
|
os.system(command)
|
||||||
sys.exit()
|
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'))
|
||||||
|
|
Loading…
Reference in a new issue