├── wanted.txt ├── config.conf ├── README.md └── CamsterRecorder.py /wanted.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /config.conf: -------------------------------------------------------------------------------- 1 | [paths] 2 | # set the path to your wishlist file 3 | wishlist = /Users/Joe/wanted.txt 4 | # set the path to the directory where the recordings will be saved 5 | save_directory = /Users/Joe/camster 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CamsterRecorder 2 | 3 | This is script to automate the recording of public webcam shows from camster. 4 | 5 | 6 | ## Requirements 7 | 8 | I have only tested this on debian(7+8) and Mac OS X (10.10.4), but it should run on other OSs 9 | 10 | Requires python3.5 or newer. You can grab python3.5.2 from https://www.python.org/downloads/release/python-352/ 11 | 12 | to install required modules, run: 13 | ``` 14 | python3.5 -m pip install livestreamer bs4 lxml gevent 15 | ``` 16 | 17 | 18 | Set the appropriate paths in the config file. 19 | 20 | Add models to the "wanted.txt" file (only one model per line). The model should match the models name in their chatrooms URL (http://camster.com/webcamcam/{modelname}/{uid}). 21 | -------------------------------------------------------------------------------- /CamsterRecorder.py: -------------------------------------------------------------------------------- 1 | import requests, os, time, datetime, random, sys, threading, configparser 2 | from bs4 import BeautifulSoup 3 | from livestreamer import Livestreamer 4 | 5 | mainDir = sys.path[0] 6 | Config = configparser.ConfigParser() 7 | Config.read(mainDir + "/config.conf") 8 | save_directory = Config.get('paths', 'save_directory') 9 | wishlist = Config.get('paths', 'wishlist') 10 | 11 | if not os.path.exists("{path}".format(path=save_directory)): 12 | os.makedirs("{path}".format(path=save_directory)) 13 | recording = [] 14 | def getOnlineModels(): 15 | wanted = [] 16 | with open(wishlist) as f: 17 | for model in f: 18 | models = model.split() 19 | for theModel in models: 20 | wanted.append(theModel.lower()) 21 | f.close() 22 | online = [] 23 | while True: 24 | try: 25 | result = requests.get("http://new.naked.com/").text 26 | soup = BeautifulSoup(result, 'lxml') 27 | for a in soup.find_all('a', href=True): 28 | if a['href'][:8] == '/webcam/': 29 | online.append(a['href']) 30 | result = requests.get("http://new.naked.com" + random.choice(online)).text 31 | soup = BeautifulSoup(result, 'lxml') 32 | break 33 | except: 34 | time.sleep(20) 35 | for model in soup.findAll("div", {"class": "each-girls"}): 36 | aux = model.findAll('a') 37 | modelName = str(aux).split('"')[3][8:].split('/')[0].lower() 38 | if modelName in wanted and modelName not in recording: 39 | link = str(aux).split('"')[11][6:] 40 | thread = threading.Thread(target=startRecording, args=(modelName, link)) 41 | thread.start() 42 | 43 | def startRecording(model, link): 44 | session = Livestreamer() 45 | 46 | streams = session.streams("hls://http://transcode.k8s-do.naked.com/hls/" + link + "/index.m3u8") 47 | stream = streams["best"] 48 | fd = stream.open() 49 | ts = time.time() 50 | st = datetime.datetime.fromtimestamp(ts).strftime("%Y.%m.%d_%H.%M.%S") 51 | if not os.path.exists("{path}/{model}".format(path=save_directory, model=model)): 52 | os.makedirs("{path}/{model}".format(path=save_directory, model=model)) 53 | with open("{path}/{model}/{st}_{model}.mp4".format(path=save_directory, model=model, 54 | st=st), 'wb') as f: 55 | recording.append(model.lower()) 56 | while True: 57 | try: 58 | data = fd.read(1024) 59 | f.write(data) 60 | except: 61 | recording.remove(model) 62 | f.close() 63 | return () 64 | 65 | if __name__ == '__main__': 66 | while True: 67 | getOnlineModels() 68 | for i in range(20, 0, -1): 69 | sys.stdout.write("\033[K") 70 | print("{} model(s) are being recorded. Next check in {} seconds".format(len(recording), i)) 71 | sys.stdout.write("\033[K") 72 | print("the followingmodels are being recorded: {}".format(recording), end="\r") 73 | time.sleep(1) 74 | sys.stdout.write("\033[F") 75 | --------------------------------------------------------------------------------