-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.py
More file actions
61 lines (53 loc) · 1.1 KB
/
common.py
File metadata and controls
61 lines (53 loc) · 1.1 KB
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
import math;
URL = "http://youtube.com";
def readable(x):
digit = 0;
i = x;
sint = str(x);
while i > 1:
i /= 10;
digit += 1;
dot = int(math.floor((digit - 1) / 3));
for i in range(0, dot):
pos = i + (3 * (i + 1));
rpos = len(sint) - pos;
sint = sint[:rpos] + "." + sint[rpos:];
return sint;
def toInt(str, splitter=","):
ls = str.split(splitter);
sint = "";
for s in ls:
sint += s;
try:
integer = int(sint);
except ValueError:
integer = 0;
return integer;
def get_month(month):
month_list = {
"Jan": 1,
"Feb": 2,
"Mar": 3,
"Apr": 4,
"May": 5,
"Jun": 6,
"Jul": 7,
"Aug": 8,
"Sep": 9,
"Oct": 10,
"Nov": 11,
"Dec": 12
};
return month_list[month];
def print_video_data(data):
print("Title : " + data["title"]);
print("Views : " + readable(data["views"]));
print("Likes : " + readable(data["likes"]));
print("Dislikes : " + readable(data["dislikes"]));
if "vpd" in data:
print("VPD : " + readable(data["vpd"]));
def print_videos_data(most_type, mList):
print("# " + most_type + ":");
for video in mList:
print_video_data(video);
print(".");