-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidators.py
56 lines (50 loc) · 1.82 KB
/
validators.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import requests
import urllib.parse as urlparse
class Validator(object):
def __init__(self, url):
self.url = url
self.type = None
def ph_type_check(self):
parsed = urlparse.urlparse(self.url)
self.type = parsed.path.split('/')[1]
if self.type == "model":
print("This is a MODEL url,")
elif self.type == "pornstar":
print("This is a PORNSTAR url,")
elif self.type == "channels":
print("This is a CHANNEL url,")
elif self.type == "users":
print("This is a USER url,")
elif self.type == "playlist":
self.type("This is a PLAYLIST url,")
elif type == "view_video.php":
print("This is a VIDEO url. Please paste a model/pornstar/user/channel/playlist url.")
sys.exit()
else:
print("Somethings wrong with the url. Please check it out.")
sys.exit()
return self.type
def ph_url_check(self):
parsed = urlparse.urlparse(self.url)
regions = ["www", "cn", "cz", "de", "es", "fr", "it", "nl", "jp", "pt", "pl", "rt"]
for region in regions:
if (parsed.netloc == region + ".pornhub.org") or (parsed.netloc == region + ".pornhub.com"):
print("PornHub url validated.")
return
print("This is not a PornHub url.")
sys.exit()
def ph_alive_check(self):
requested = requests.get(self.url)
if requested.status_code == 200:
print("and the URL is existing.")
else:
print("but the URL does not exist.")
sys.exit()
def run(self):
self.type = self.ph_url_check()
self.ph_type_check()
self.ph_alive_check()
return self.type
def get_type(self):
return self.type