示例#1
0
 def select_date(self):
     # すべての日付
     name = '[COLOR lightgreen]%s[/COLOR]' % Common.STR(30912)
     if self.args.get('ch') is None:
         mode = 'selectChannel'
     elif self.args.get('g0') is None:
         mode = 'selectGenre'
     else:
         mode = 'search'
     self.add_directory_item(name, '%s&sdate=&edate=' % self.query, mode, iconimage=Common.CALENDAR)
     # 月,火,水,木,金,土,日
     w = Common.STR(30920).split(',')
     for i in range(120):
         d = datetime.date.today() - datetime.timedelta(i)
         wd = d.weekday()
         # 月日
         # date1 = '%s(%s)' % (d.strftime(Common.STR(30919)), w[wd])
         date1 = '%s(%s)' % (Common.strftime(d, Common.STR(30919)), w[wd])
         date2 = d.strftime('%Y-%m-%d')
         if Common.isholiday(date2) or wd == 6:
             name = '[COLOR red]%s[/COLOR]' % date1
         elif wd == 5:
             name = '[COLOR blue]%s[/COLOR]' % date1
         else:
             name = date1
         query = '%s&sdate=%s 00:00:00&edate=%s 23:59:59' % (self.query, date2, date2)
         if self.args.get('ch') is None:
             mode = 'selectChannel'
         elif self.args.get('g0') is None:
             mode = 'selectGenre'
         else:
             mode = 'search'
         self.add_directory_item(name, query, mode, iconimage=Common.CALENDAR)
     # end of directory
     xbmcplugin.endOfDirectory(int(sys.argv[1]))
示例#2
0
 def show_history(self, name):
     # ディレクトリ
     cache_dir = os.path.join(Common.CACHE_PATH, name)
     if not os.path.isdir(cache_dir):
         os.makedirs(cache_dir)
     # ファイルリスト
     count = 0
     files = sorted(os.listdir(cache_dir),
                    key=lambda message: os.stat(
                        os.path.join(cache_dir, message)).st_mtime,
                    reverse=True)
     for filename in files:
         path = os.path.join(cache_dir, filename)
         if os.path.isfile(path) and not filename.startswith('.'):
             if self.listsize == 0 or count < self.listsize:
                 content = Common.read_file(path)
                 # 日付文字列
                 d = datetime.datetime.fromtimestamp(os.stat(path).st_mtime)
                 weekday = d.weekday()
                 date1 = Common.strftime(
                     d, Common.STR(32901)
                 ) + '(%s)' % Common.STR(32902).split(',')[weekday]
                 time1 = d.strftime('%H:%M:%S')
                 if weekday == 6 or Common.isholiday(
                         d.strftime('%Y-%m-%d')):
                     template = '[COLOR red]%s %s[/COLOR]'
                 elif weekday == 5:
                     template = '[COLOR blue]%s %s[/COLOR]'
                 else:
                     template = '%s %s'
                 fd = template % (date1, time1)
                 # リストアイテム
                 label = '%s  %s' % (fd, content)
                 listitem = xbmcgui.ListItem(label)
                 listitem.setArt({
                     'iconImage': 'DefaultFile.png',
                     'thumb': 'DefaultFile.png'
                 })
                 values = {'action': 'message', 'name': name, 'path': path}
                 query = '%s?%s' % (sys.argv[0], urlencode(values))
                 # コンテクストメニュー
                 menu = []
                 # アドオン設定
                 menu.append((Common.STR(32900),
                              'Addon.OpenSettings(%s)' % Common.ADDON_ID))
                 # 追加
                 listitem.addContextMenuItems(menu, replaceItems=True)
                 xbmcplugin.addDirectoryItem(int(sys.argv[1]), query,
                                             listitem, False)
                 # カウントアップ
                 count += 1
             else:
                 os.remove(path)
     # end of directory
     xbmcplugin.endOfDirectory(int(sys.argv[1]))