v.2.1.0 Cam4 Anonymous Get Online All Models for Python3.12

This commit is contained in:
horacio9a 2024-03-18 09:46:38 +01:00 committed by GitHub
parent 2b8fbaf149
commit 094c392ebf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,38 +1,36 @@
# Cam4 Anonymous Get Online All Models v.2.0.1 by horacio9a for Python 3.9.1
# Cam4 Anonymous Get Online All Models v.2.1.0 by horacio9a for Python 3.12.2
# coding: utf-8
import sys, os, urllib, ssl, re, json, gevent, requests
import sys, os, urllib, ssl, re, json, requests
offline = False
import configparser
Config = configparser.ConfigParser()
Config.read('config3.ini')
country_domain = Config.get('settings', 'country_domain')
def getOnlineUsers(page):
attempt = 1
while attempt <= 3:
try:
timeout = gevent.Timeout(8)
timeout.start()
result = urllib.request.urlopen("https://www.cam4.com/directoryCams?directoryJson=true&online=true&url=true&page={}".format(page))
result = result.read()
results = json.loads(result.decode())
return results
except gevent.Timeout:
attempt = attempt + 1
if attempt > 1:
sys.exit()
attempt = 1
while attempt < 3:
try:
results = requests.get("https://{}.cam4.com/directoryCams?directoryJson=true&online=true&url=true&page={}".format(country_domain, page)).json()
return results
except:
attempt = attempt + 1
if __name__ == '__main__':
while True:
attempt = 1
online = []
while not offline:
results = getOnlineUsers(attempt)
if len(results['users']) > 1:
online.extend([user['username'] for user in results['users']])
else:
offline = True
attempt = attempt + 1
offline = False
for username in online:
online_all_model_list = username.lower()
print(online_all_model_list)
if attempt > 3:
sys.exit()
while True:
attempt = 1
online = []
while not offline:
results = getOnlineUsers(attempt)
if len(results['users']) > 1:
online.extend([user['username'] for user in results['users']])
else:
offline = True
attempt = attempt + 1
offline = False
for username in online:
online_all_model_list = username
print(online_all_model_list)
if attempt > 3:
sys.exit()