This repository has been archived by the owner on Mar 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 209
/
yt.py
executable file
·99 lines (76 loc) · 2.53 KB
/
yt.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
from lib.multi import Threader
from lib.auth import *
import lib.execption as err
import lib.action as YT
import lib.cli as cli
import threading
import signal
cli.banner()
action = cli.ask_action()
threader = Threader(cli.ask_threads())
accounts_path = cli.ask_accounts_file()
action_path = cli.ask_action_file()
slogin = 0
flogin = 0
saction = 0
faction = 0
clock = threading.Lock()
lock = threading.Lock()
botgaurd = Botgaurd()
server = botgaurd.server_start()
def counters(name,value=1):
global slogin
global flogin
global saction
global faction
global clock
mapping = {
'login-t': 'slogin',
'login-f': 'flogin',
'action-t': 'saction',
'action-f': 'faction',
}
with clock:
globals()[mapping[name]] += value
cli.show_status(slogin, flogin, saction, faction)
def youtube_session(email,password):
try:
authenticator = GAuth(email, password)
authenticator.set_botguard_server(server)
google = authenticator.Glogin()
status = authenticator.ServiceLogin('youtube','https://www.youtube.com/signin?app=desktop&next=%2F&hl=en&action_handle_signin=true')
counters('login-t')
return status
except err.LoginFailed:
counters('login-f')
return -1
def like_wrapper(email,password,video_id):
session = youtube_session(email, password)
if session == -1:
cli.debug("Like: [%s:%s]:UNAUTH -> %s:0" %(email,password,video_id) )
counters('login-f')
return "unauthenticated"
status = YT.like(video_id, session)
counters('action-t') if status == 1 else counters('action-f')
cli.debug("Like: [%s]:LOGGED -> %s:%i" %(email,video_id,status))
def subscribe_wrapper(email,password,channel_id):
session = youtube_session(email, password)
if session == -1:
cli.debug("Sub: [%s:%s]:UNAUTH -> %s:0" %(email,password,channel_id) )
counters('action-f')
return "authenticated"
status = YT.subscribe(channel_id, session)
counters('action-t') if status == 1 else counters('action-f')
cli.debug("Sub: [%s]:LOGGED -> %s:%i" %(email,channel_id,status))
def on_exit(sig, frame):
botgaurd.server_shutdown()
cli.sys.exit(0)
signal.signal(signal.SIGINT, on_exit)
for identifier in cli.read_action_file(action_path):
for credentials in cli.read_acounts_file(accounts_path):
if action == "l":
threader.put(like_wrapper,[credentials[0],credentials[1],identifier])
elif action == "s":
threader.put(subscribe_wrapper,[credentials[0],credentials[1],identifier])
threader.finish_all()
botgaurd.server_shutdown()