-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube-video-view.py
148 lines (124 loc) · 5.89 KB
/
youtube-video-view.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import os
import random
from time import sleep
from selenium import webdriver
from urllib.request import Request, urlopen
from bs4 import BeautifulSoup
from fake_useragent import UserAgent
from utils import read_proxies_file
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
# Credit to Pycenter by billythegoat356
# Github: https://github.com/billythegoat356/pycenter/
# License: https://github.com/billythegoat356/pycenter/blob/main/LICENSE
# def center(var: str, space: int = None): # From Pycenter
# if not space:
# space = (os.get_terminal_size().columns -
# len(var.splitlines()[int(len(var.splitlines())/2)])) / 2
# return "\n".join((' ' * int(space)) + var for var in var.splitlines())
class Fore:
YELLOW = '\033[93m'
GREEN = '\033[32m'
RED = '\033[91m'
CYAN = '\033[36m'
RESET = '\033[0m'
proxies = []
def banner():
os.system(
'cls && title [YT View Bot v2] - Made by Plasmonix' if os.name == "nt" else 'clear')
text = '''
▓██ ██▓▄▄▄█████▓ ██▒ █▓ ██▓▓█████ █ █░ ▄▄▄▄ ▒█████ ▄▄▄█████▓
▒██ ██▒▓ ██▒ ▓▒ ▓██░ █▒▓██▒▓█ ▀ ▓█░ █ ░█░ ▓█████▄ ▒██▒ ██▒▓ ██▒ ▓▒
▒██ ██░▒ ▓██░ ▒░ ▓██ █▒░▒██▒▒███ ▒█░ █ ░█ ▒██▒ ▄██▒██░ ██▒▒ ▓██░ ▒░
░ ▐██▓░░ ▓██▓ ░ ▒██ █░░░██░▒▓█ ▄ ░█░ █ ░█ ▒██░█▀ ▒██ ██░░ ▓██▓ ░
░ ██▒▓░ ▒██▒ ░ ▒▀█░ ░██░░▒████▒░░██▒██▓ ░▓█ ▀█▓░ ████▓▒░ ▒██▒ ░
██▒▒▒ ▒ ░░ ░ ▐░ ░▓ ░░ ▒░ ░░ ▓░▒ ▒ ░▒▓███▀▒░ ▒░▒░▒░ ▒ ░░
▓██ ░▒░ ░ ░ ░░ ▒ ░ ░ ░ ░ ▒ ░ ░ ▒░▒ ░ ░ ▒ ▒░ ░
▒ ▒ ░░ ░ ░░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ '''
faded = ''
cyan = 100
for line in text.splitlines():
faded += (f"\033[38;2;0;255;{cyan}m{line}\033[0m\n")
if not cyan == 255:
cyan += 15
if cyan > 255:
cyan = 255
# print(center(faded))
# print(
# center(f'{Fore.YELLOW}\ngithub.com/Plasmonix Version 2.0{Fore.RESET}'))
def load_proxies():
try:
proxyfile = open(fp, "r+").readlines()
for proxy in proxyfile:
ip = proxy.split(":")[0]
port = proxy.split(":")[1]
proxies.append({
'ip': ip.rstrip("\n"),
'port': port.rstrip("\n")})
except:
print(f'[{Fore.RED}!{Fore.RESET}] {Fore.RED}File not found{Fore.RESET}')
quit()
ua = UserAgent()
def scrape_proxies():
try:
proxies_req = Request('https://www.sslproxies.org/')
proxies_req.add_header('User-Agent', ua.random)
proxies_doc = urlopen(proxies_req).read().decode('utf8')
soup = BeautifulSoup(proxies_doc, 'html.parser')
proxies_table = soup.find(
'table', attrs={'class': 'table table-striped table-bordered'})
for row in proxies_table.tbody.find_all('tr'):
proxies.append({
'ip': row.find_all('td')[0].string,
'port': row.find_all('td')[1].string})
except:
print(
f'[{Fore.RED}!{Fore.RESET}] {Fore.RED}Failed to scrape proxies{Fore.RESET}')
quit()
def load_url(videoname,url,ua, sleeptime, proxy):
options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=%s' %
(proxy['ip'] + ':' + proxy['port']))
options.add_argument('user-agent=%s' % ua.random)
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(service=Service(
ChromeDriverManager().install()), options=options)
videoquery='+'.join(videoname.split(' '))
searchurl='https://www.youtube.com/results?search_query='+videoquery
driver.get(searchurl)
sleep(20)
driver.get(url)
sleep(sleeptime)
driver.quit()
if __name__ == "__main__":
banner()
try:
items = []
scrape_proxies()
for proxyType in ['http','socks4','socks5']:
proxyList = read_proxies_file()
proxies.extend(proxyList)
with open('urls.txt', 'r', encoding='utf8') as f:
items = f.readlines()
for item in items:
views = 200
minwatch = 60
maxwatch = 180
videoname=item.split(',')[-1]
url=item.split(',')[0]
for i in range(views):
sleeptime = random.randint(minwatch, maxwatch)
proxy = random.choice(proxies)
load_url(videoname,url,ua, sleeptime, proxy)
except ValueError:
print(
f'[{Fore.RED}!{Fore.RESET}] {Fore.RED}Value must be an integer{Fore.RESET}')
quit()
# os.system('cls')
# banner()
# for i in range(views):
# sleeptime = random.randint(minwatch,maxwatch)
# proxy = random.choice(proxies)
# load_url(ua, sleeptime, proxy)