[403d30]: plugin.video.hockeystreams / abstract.py Maximize Restore History

Download this file

abstract.py    60 lines (48 with data), 2.0 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
import datetime
__author__ = 'longman'
class AbstractHockey(object):
def __init__(self, util):
today = datetime.date.today()
self.util = util
self.today = today
self.archiveDate = self.get_date(today.day, today.month, today.year)
def get_date(self, day, month, year):
archiveMonth = str(month)
if len(archiveMonth) == 1:
archiveMonth = '0' + archiveMonth
archiveDay = str(day)
if len(archiveDay) == 1:
archiveDay = '0' + archiveDay
archiveDate = '-'.join([archiveMonth, archiveDay, str(year)])
return archiveDate
def YEAR(self, url, mode):
self.util.addDir(self.util.__settings__.getLocalizedString(40200), url, 6, '', 1)
for year in range(self.today.year, 2009, -1):
if year == self.today.year:
monthsCount = self.today.month
else:
monthsCount = 12
self.util.addDir(str(year), url, mode, '', monthsCount, year)
def MONTH(self, url, year, mode):
if year == self.today.year:
startmonth = self.today.month
else:
startmonth = 12
for month in range(startmonth, 0, -1):
patsy = datetime.date(int(year), int(month), 1)
days_in_month = int(patsy.strftime("%d"))
if month == patsy.month:
daysCount = self.today.day
else:
daysCount = days_in_month
self.util.addDir(patsy.strftime("%B"), url, mode, '', daysCount, year, month)
def DAY(self, url, year, month, mode):
startday = 31
if year == self.today.year and month == self.today.month:
startday = self.today.day
for day in range(startday, 0, -1):
try:
patsy = datetime.date(year, month, day)
self.util.addDir(patsy.strftime("%x"), url, mode, '', 1, year, month, day)
except ValueError:
pass # skip day