mirror of
https://github.com/horacio9a/cam4-anonymous.git
synced 2025-01-16 20:31:20 +08:00
v.2.0.0 Cam4 Anonymous Get Online Wanted Models for Python27
This commit is contained in:
parent
636dd6da97
commit
9e91abdc02
1 changed files with 51 additions and 0 deletions
51
C4_getOnlineWantedModels.py
Normal file
51
C4_getOnlineWantedModels.py
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# Cam4 Anonymous Get Online Wanted Models v.2.0.0 by horacio9a for Python 2.7.18
|
||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
import sys, os, urllib, ssl, re, json, configparser, requests
|
||||||
|
from sys import exit
|
||||||
|
Config = configparser.ConfigParser()
|
||||||
|
|
||||||
|
setting = {}
|
||||||
|
|
||||||
|
def readConfig():
|
||||||
|
global setting
|
||||||
|
Config.read('config.ini')
|
||||||
|
setting = {'wanted_model_list': Config.get('files', 'wanted_model_list')}
|
||||||
|
|
||||||
|
offline = False
|
||||||
|
|
||||||
|
def getOnlineModels(page):
|
||||||
|
attempt = 1
|
||||||
|
while attempt < 3:
|
||||||
|
try:
|
||||||
|
results = requests.get("https://www.cam4.com/directoryCams?directoryJson=true&online=true&url=true&page={}".format(page)).json()
|
||||||
|
return results
|
||||||
|
except:
|
||||||
|
attempt = attempt + 1
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
while True:
|
||||||
|
readConfig()
|
||||||
|
wanted_model_list = []
|
||||||
|
attempt = 1
|
||||||
|
with open(setting['wanted_model_list']) as f:
|
||||||
|
for model in f:
|
||||||
|
models = model.split()
|
||||||
|
for theModel in models:
|
||||||
|
wanted_model_list.append(theModel.lower())
|
||||||
|
online = []
|
||||||
|
while not offline:
|
||||||
|
results = getOnlineModels(attempt)
|
||||||
|
if len(results['users']) > 1:
|
||||||
|
online.extend([user['username'].lower() for user in results['users']])
|
||||||
|
else:
|
||||||
|
offline = True
|
||||||
|
attempt = attempt + 1
|
||||||
|
offline = False
|
||||||
|
for model in list(set(set(online)).intersection(set(wanted_model_list))):
|
||||||
|
online_model_list = online
|
||||||
|
for online_wanted_model_list in online_model_list:
|
||||||
|
if online_wanted_model_list in wanted_model_list:
|
||||||
|
print(online_wanted_model_list)
|
||||||
|
if attempt > 3:
|
||||||
|
exit(0)
|
Loading…
Reference in a new issue