2021-05-23 07:29:14 +08:00
|
|
|
# Cam4 Remote Anonymous STREAMLINK Recorder v.2.0.0 by horacio9a for Python 2.7.18
|
2021-04-21 02:35:09 +08:00
|
|
|
# coding: utf-8
|
2017-12-08 22:16:50 +08:00
|
|
|
|
2021-05-23 07:29:14 +08:00
|
|
|
import sys, os, urllib, urllib3, ssl, re, time, datetime, requests, random, command
|
2017-12-08 22:16:50 +08:00
|
|
|
urllib3.disable_warnings()
|
|
|
|
from urllib3 import PoolManager
|
|
|
|
reload(sys)
|
|
|
|
sys.setdefaultencoding('utf-8')
|
|
|
|
from colorama import init, Fore, Back, Style
|
|
|
|
from termcolor import colored
|
2021-05-23 07:29:14 +08:00
|
|
|
import configparser
|
|
|
|
Config = configparser.ConfigParser()
|
|
|
|
Config.read('config.ini')
|
2017-12-08 22:16:50 +08:00
|
|
|
|
|
|
|
init()
|
2021-05-23 07:29:14 +08:00
|
|
|
print
|
|
|
|
print(colored(' => START <=', 'white', 'on_blue'))
|
|
|
|
print
|
2017-12-08 22:16:50 +08:00
|
|
|
|
|
|
|
if __name__=='__main__':
|
|
|
|
import sys
|
|
|
|
model = sys.argv[1]
|
|
|
|
|
2021-05-23 07:29:14 +08:00
|
|
|
url ='https://www.cam4.com/rest/v1.0/profile/{}/streamInfo'.format(model)
|
2021-04-25 14:06:09 +08:00
|
|
|
manager = PoolManager(10)
|
|
|
|
r = manager.request('GET', url)
|
2017-12-10 18:41:35 +08:00
|
|
|
enc = (r.data)
|
2021-04-25 14:06:09 +08:00
|
|
|
dec=urllib.unquote(enc)
|
2017-12-08 22:16:50 +08:00
|
|
|
|
2021-05-23 07:29:14 +08:00
|
|
|
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()
|
|
|
|
|
|
|
|
timestamp = str(time.strftime('%d%m%Y-%H%M%S'))
|
|
|
|
stime = str(time.strftime('%H:%M:%S'))
|
|
|
|
path = Config.get('folders', 'output_folder')
|
|
|
|
streamlink = Config.get('files', 'streamlink')
|
|
|
|
filename = streamName + '_C4_' + timestamp + '.mp4'
|
|
|
|
pf = path + filename
|
|
|
|
print (colored(' => SL-REC => {} ( Size @ Speed )', 'white', 'on_red')).format(filename)
|
|
|
|
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))
|
|
|
|
os.system(command)
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
else:
|
|
|
|
sys.exit()
|
2018-01-03 19:04:22 +08:00
|
|
|
|
|
|
|
else:
|
2021-05-23 07:29:14 +08:00
|
|
|
print(colored(' => Model is offline or wrong name <=', 'white','on_red'))
|
2021-04-22 03:01:40 +08:00
|
|
|
print
|
|
|
|
print(colored(' => END <=', 'white','on_blue'))
|
2021-05-23 07:29:14 +08:00
|
|
|
sys.exit()
|