-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotherFunc.py
119 lines (83 loc) · 3.32 KB
/
otherFunc.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
import re
import requests
def getSubbed():
try:
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\channelnames.txt')
chanLinksList = allChanName.readlines()
allChanName.close()
namesList = []
for info in chanLinksList:
namesList.append(info.split('==')[0])
return namesList
except:
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\channelnames.txt', 'x')
allChanName.close()
return []
def getLists():
try:
allPlayName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\playlistnames.txt')
playLinksList = allPlayName.readlines()
allPlayName.close()
namesList = []
for info in playLinksList:
namesList.append(info.split('==')[0])
return namesList
except:
allPlayName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\playlistnames.txt', 'x')
allPlayName.close()
return []
def addSubbed(URL, name):
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\channelnames.txt', 'a')
allChanName.write(name + "==" + URL + "\n")
allChanName.close()
def addList(URL, name):
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\playlistnames.txt', 'a')
allChanName.write(name + "==" + URL + "\n")
allChanName.close()
def rmSubbed(name):
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\channelnames.txt', 'r')
lines = allChanName.readlines()
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\channelnames.txt', 'w')
for line in lines:
if line.split('==')[0] != name:
allChanName.write(line)
allChanName.close()
def rmList(name):
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\playlistnames.txt', 'r')
lines = allChanName.readlines()
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\playlistnames.txt', 'w')
for line in lines:
if line.split('==')[0] != name:
allChanName.write(line)
allChanName.close()
def getVideosLink(name):
allChanName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\channelnames.txt')
while True:
line = allChanName.readline()
if line.split('==')[0] == name:
return line.split('==')[1]
def getListsLink(name):
allPlayName = open('C:\\Users\\dlneh\\Documents\\home\\cs projects\\me_tube\\playlistnames.txt')
while True:
line = allPlayName.readline()
if line.split('==')[0] == name:
return line.split('==')[1]
def getAllVideos(name):
link = getVideosLink(name)
r = requests.get(link)
info = r.text
findLinks = re.compile('"gridVideoRenderer":\{"videoId":"[a-zA-Z0-9]+","')
allLinks = re.findall(findLinks, info)
vidEmbed = []
for link in allLinks:
id = link.split('"')[5]
vidEmbed.append('https://www.youtube.com/embed/' + id)
return vidEmbed
def getVidColNums(embedList):
numCol = 5 # 5 columns in video page
counter = 0
colDict = {}
for link in embedList:
colDict[link] = (counter % numCol) + 1
counter += 1
return colDict