-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
93 lines (90 loc) · 2.66 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import random, string
import os, sys
import requests as r
import time as t
from termcolor import colored as cl
from fake_useragent import UserAgent
from lxml.html import fromstring
#import urllib.request
#from bs4 import BeautifulSoup
ua = UserAgent()
def clear():
clear = input(cl('clear text files (yes or no): ', 'white'))
if clear == 'yes':
pick = input(cl('valid, notvalid, or both: ', 'white'))
if pick == 'valid':
file = open("YESvalid.txt", "w+")
file.write("")
file.close()
elif pick == 'notvalid':
file = open("NOTvalid.txt", "w+")
file.write("")
file.close()
elif pick == 'both':
file = open("YESvalid.txt", "w+")
file.write("")
file.close()
file = open("NOTvalid.txt", "w+")
file.write("")
file.close()
else:
print('\033[H\033[J')
print(cl('invalid choice', 'red'))
t.sleep(3)
os.system('python3 main.py')
elif clear == 'no':
print('files wont be cleared\n')
else:
print('\033[H\033[J')
print(cl('invalid choice', 'red'))
t.sleep(3)
print('\033[H\033[J')
os.system('python3 main.py')
print(cl('tubegen v1.0', 'green'))
choice = input(cl('fast or slow: ', 'white'))
if choice == "fast":
speed = 0.2
clear()
elif choice == "slow":
speed = 0.6
clear()
else:
print(cl('invalid choice', 'red'))
t.sleep(3)
print('\033[H\033[J')
os.system('python3 main.py')
attempt = 0
while True:
def get_random_string(length):
random_list = []
for i in range(length):
random_list.append(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits + '-' + '_'))
return ''.join(random_list)
url = "https://www.youtube.com/watch?v=" + get_random_string(11)
a = ua.random
headers = {
'User-Agent': a
}
res = r.get(url, headers=headers)
if res.status_code == 429:
print('\033[H\033[J')
sys.exit('error 429 - too many requests ):\n')
else:
#soup = BeautifulSoup(urllib.request.urlopen(url), features="html5lib")
tree = fromstring(res.content)
title = tree.findtext('.//title')
if title == " - YouTube" or "YouTube":
valid = "no (" + title + ")"
color = "red"
file = open("NOTvalid.txt", "a+")
file.write('url: "' + url + '"\nuser-agent: "' + a + '"\n\n')
file.close()
elif title != " - YouTube":
valid = "yes (" + title + ")"
color = "green"
file = open("YESvalid.txt", "a+")
file.write('url: "' + url + '"\nuser-agent: "' + a + '"\n\n')
file.close()
attempt = attempt + 1
print('youtube url: ' + url + '\nis valid: ' + cl(valid, color) + '\nattempt: ' + cl(str(attempt), 'cyan') + '\n')
t.sleep(speed)