コード例 #1
0
def load_favorite_tv_shows(req_attrib, modelMap):
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(),
                                      extraDirPath='data',
                                      filename='DTB_Favorites.json',
                                      makeDirs=False)
    logging.getLogger().debug('loading favorite tv shows from file : %s' %
                              filepath)
    favorite_tv_shows = _read_favorite_tv_shows_cache_(filepath)
    if favorite_tv_shows is None:
        return
    favorite_tv_shows_items = []
    tv_show_names = favorite_tv_shows.keys()
    tv_show_names.sort()
    for tv_show_name in tv_show_names:
        favorite_tv_show = favorite_tv_shows[tv_show_name]
        item = xbmcgui.ListItem(
            label=tv_show_name,
            iconImage=favorite_tv_show['tv-show-thumb'],
            thumbnailImage=favorite_tv_show['tv-show-thumb'])
        item.setProperty('channel-type', favorite_tv_show['channel-type'])
        item.setProperty('channel-name', favorite_tv_show['channel-name'])
        item.setProperty('tv-show-name', tv_show_name)
        item.setProperty('tv-show-url', favorite_tv_show['tv-show-url'])
        item.setProperty('tv-show-thumb', favorite_tv_show['tv-show-thumb'])
        favorite_tv_shows_items.append(item)

    modelMap['favorite_tv_shows_items'] = favorite_tv_shows_items
コード例 #2
0
ファイル: dtf_actions.py プロジェクト: noba3/KoTos
def check_cache(req_attrib, modelMap):
    logging.getLogger().debug('Check cache for DTF ***********************')
    logging.getLogger().debug(req_attrib)
    refresh_cache = True
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(),
                                      extraDirPath='data',
                                      filename='DTF_Channels.json',
                                      makeDirs=True)
    logging.getLogger().debug(filepath)
    refresh = context.get_addon().getSetting('dtfForceRefresh')
    if refresh == None or refresh != 'true':
        modified_time = file.get_last_modified_time(filepath)
        if modified_time is not None:
            diff = long((time.time() - modified_time) / 3600)
            if diff < 720:
                refresh_cache = False
            else:
                logging.getLogger().debug(
                    'DTF_Channels.json was last created 30 days ago, refreshing data.'
                )
    else:
        logging.getLogger().debug('Request to force refresh.')
    modelMap['refresh_cache'] = refresh_cache
    modelMap['cache_filepath'] = filepath
コード例 #3
0
ファイル: dtb_actions.py プロジェクト: RozebMomin/KodiAddons
def remove_favorite(req_attrib, modelMap):
    logging.getLogger().debug('remove tv show favorite...')
    favorite = CacheManager().get('selected_favorite')
    favorite_thumb = CacheManager().get('selected_favorite_thumb')
    favorites = CacheManager().get('tv_favorites')
    if favorites is None:
        favorites = {}
    elif favorites.has_key(favorite):
        favorites.pop(favorite)
    
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Favorites.json', makeDirs=False)
    logging.getLogger().debug(favorites)
    _write_favorite_tv_shows_cache_(filepath, favorites)
    
    notification = "XBMC.Notification(%s,%s,%s,%s)" % (favorite, 'REMOVED FAVORITE', 2500, favorite_thumb)
    xbmc.executebuiltin(notification)
    
    modelMap['reload_favorite_tv_shows_items'] = True
    if len(favorites) > 0:
        favorite_tv_shows_items = []
        for tv_show_name in favorites:
            favorite_tv_show = favorites[tv_show_name]
            item = xbmcgui.ListItem(label=tv_show_name, iconImage=favorite_tv_show['tv-show-thumb'], thumbnailImage=favorite_tv_show['tv-show-thumb'])
            item.setProperty('channel-type', favorite_tv_show['channel-type'])
            item.setProperty('channel-name', favorite_tv_show['channel-name'])
            item.setProperty('tv-show-name', tv_show_name)
            item.setProperty('tv-show-url', favorite_tv_show['tv-show-url'])
            item.setProperty('tv-show-thumb', favorite_tv_show['tv-show-thumb'])
            favorite_tv_shows_items.append(item)
            
        modelMap['favorite_tv_shows_items'] = favorite_tv_shows_items
コード例 #4
0
def add_tv_show_favorite(req_attrib, modelMap):
    logging.getLogger().debug('add tv show favorite...')
    tv_show_url = req_attrib['tv-show-url']
    tv_show_name = req_attrib['tv-show-name']
    tv_show_thumb = req_attrib['tv-show-thumb']
    channel_type = req_attrib['channel-type']
    channel_name = req_attrib['channel-name']
    logging.getLogger().debug('add tv show favorite...' + tv_show_url)

    favorites = CacheManager().get('dtb_tv_favorites')
    if favorites is None:
        favorites = {}
    elif favorites.has_key(tv_show_name):
        favorites.pop(tv_show_name)

    favorites[tv_show_name] = {
        'tv-show-name': tv_show_name,
        'tv-show-thumb': tv_show_thumb,
        'tv-show-url': tv_show_url,
        'channel-name': channel_name,
        'channel-type': channel_type
    }
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(),
                                      extraDirPath='data',
                                      filename='DTB_Favorites.json',
                                      makeDirs=False)
    logging.getLogger().debug(favorites)
    _write_favorite_tv_shows_cache_(filepath, favorites)

    notification = "XBMC.Notification(%s,%s,%s,%s)" % (
        tv_show_name, 'ADDED TO FAVORITES', 2500, tv_show_thumb)
    xbmc.executebuiltin(notification)
コード例 #5
0
ファイル: context.py プロジェクト: kevintone/tdbaddon
 def __init__(self, addon_context_files, addon, addon_path, addon_data_path):
     self._addon = addon
     self._addon_path = addon_path
     self._addon_data_path = addon_data_path
     
     self._xoze = Actions()
     for filepath in addon_context_files:
         self._load_actions(file.resolve_file_path(baseDirPath=addon_path, filename=filepath))
     self._initialize_mvc()
コード例 #6
0
ファイル: context.py プロジェクト: kevintone/tdbaddon
 def __initialize__(self, context):
     snapper_filepath = file.resolve_file_path(context.get_addon_path(), extraDirPath='xoze/snapvideo', filename='snappers.xml', makeDirs=False)
     self._snappers = []
     logging.getLogger().debug('Loading snappers.xml from path... ' + snapper_filepath)
     actions_elem = ET.parse(open(snapper_filepath, "r")).getroot()
     for elem in actions_elem.getchildren():
         if elem.tag == '{0}snapper'.format(NAMESPACE_SNAPPER):
                 if elem.attrib.has_key('enabled') and elem.attrib['enabled'] == 'true':
                     self._snappers.append(Snapper(elem, context.get_addon_path()))
         else:
             logging.getLogger().error('found UNKNOWN tag: <%s>' % (elem))
コード例 #7
0
ファイル: context.py プロジェクト: noba3/KoTos
    def __init__(self, addon_context_files, addon, addon_path,
                 addon_data_path):
        self._addon = addon
        self._addon_path = addon_path
        self._addon_data_path = addon_data_path

        self._xoze = Actions()
        for filepath in addon_context_files:
            self._load_actions(
                file.resolve_file_path(baseDirPath=addon_path,
                                       filename=filepath))
        self._initialize_mvc()
コード例 #8
0
ファイル: dtb_actions.py プロジェクト: RozebMomin/KodiAddons
def load_channels(req_attrib, modelMap):
    logging.getLogger().debug('load channels...')
    tv_channels = _read_tv_channels_cache_(modelMap['cache_filepath'])['channels']
    
    tv_channel_items = []
    live_tv_channel_items = []
    
    display_channel_type = 1
    
    live_channels_all = {}
    live_channels_all.update(LIVE_CHANNELS)
    
    live_filepath = file.resolve_file_path(AddonContext().get_addon_data_path(), extraDirPath='data', filename='Live.json', makeDirs=True)
    live_file_channels = _read_live_tv_channels_cache_(live_filepath)
    if live_file_channels is not None:
        live_channels_all.update(live_file_channels)
    
    channel_names = live_channels_all.keys()
    channel_names.sort()
    for channel_name in channel_names:
        channel_obj = live_channels_all[channel_name]
        if((display_channel_type == 1 and channel_obj['channelType'] == CHANNEL_TYPE_IND)  or (display_channel_type == 0)):
            item = xbmcgui.ListItem(label=channel_name, iconImage=channel_obj['iconimage'], thumbnailImage=channel_obj['iconimage'])
            item.setProperty('channel-name', channel_name)
            item.setProperty('live-link', 'true')
            item.setProperty('direct-link', 'false')
            live_tv_channel_items.append(item)
    
    for channel_name in DIRECT_CHANNELS:
        channel_obj = DIRECT_CHANNELS[channel_name]
        if((display_channel_type == 1 and channel_obj['channelType'] == CHANNEL_TYPE_IND)  or (display_channel_type == 0)):
            item = xbmcgui.ListItem(label=channel_name, iconImage=channel_obj['iconimage'], thumbnailImage=channel_obj['iconimage'])
            item.setProperty('channel-name', channel_name)
            item.setProperty('direct-link', 'true')
            item.setProperty('live-link', 'false')
            tv_channel_items.append(item)
    
    channel_names = tv_channels.keys()
    channel_names.sort()
    for channel_name in channel_names:
        channel_obj = tv_channels[channel_name]
        if ((display_channel_type == 1 and channel_obj['channelType'] == CHANNEL_TYPE_IND) 
            or (display_channel_type == 2 and channel_obj['channelType'] == CHANNEL_TYPE_PAK) 
            or (display_channel_type == 0)):
            
            item = xbmcgui.ListItem(label=channel_name, iconImage=channel_obj['iconimage'], thumbnailImage=channel_obj['iconimage'])
            item.setProperty('channel-name', channel_name)
            item.setProperty('direct-link', 'false')
            item.setProperty('live-link', 'false')
            tv_channel_items.append(item)
     
    modelMap['tv_channel_items'] = tv_channel_items
    modelMap['live_tv_channel_items'] = live_tv_channel_items
コード例 #9
0
ファイル: dtb_actions.py プロジェクト: RozebMomin/KodiAddons
def watch_live(req_attrib, modelMap):
    channel_name = req_attrib['channel-name']
    
    live_filepath = file.resolve_file_path(AddonContext().get_addon_data_path(), extraDirPath='data', filename='Live.json', makeDirs=True)
    live_file_channels = _read_live_tv_channels_cache_(live_filepath)
    tv_channel = None
    if LIVE_CHANNELS.has_key(channel_name):
        tv_channel = LIVE_CHANNELS[channel_name]
    if live_file_channels is not None and live_file_channels.has_key(channel_name):
        tv_channel = live_file_channels[channel_name]
        
    item = xbmcgui.ListItem(label=channel_name, iconImage=tv_channel['iconimage'], thumbnailImage=tv_channel['iconimage'])
    item.setProperty('streamLink', tv_channel['channelUrl'])
    modelMap['live_item'] = item
コード例 #10
0
ファイル: context.py プロジェクト: kevintone/tdbaddon
 def _load_actions(self, filepath):
     """loads content of xoze.xml in python objects. this should be STEP 1 for starting application."""
     _filepath = file.resolve_file_path(filepath)
     logging.getLogger().info('reading actions from file: <%s>, which exists: <%s>' % (_filepath, file.does_file_exist(_filepath)))
     
     actions_elem = ET.parse(open(_filepath, "r")).getroot()
     for elem in actions_elem.getchildren():
         if elem.tag == '{0}action'.format(NAMESPACE):
             self._xoze.actions.append(self._load_action(elem))
         elif elem.tag == '{0}service'.format(NAMESPACE):
             self._xoze.services.append(self._load_service(elem))
         elif elem.tag == '{0}view'.format(NAMESPACE):
             self._xoze.views.append(self._load_view(elem))
         else:
             logging.getLogger().error('found UNKNOWN tag: <%s>' % (elem))
コード例 #11
0
ファイル: context.py プロジェクト: noba3/KoTos
    def _load_actions(self, filepath):
        """loads content of xoze.xml in python objects. this should be STEP 1 for starting application."""
        _filepath = file.resolve_file_path(filepath)
        logging.getLogger().info(
            'reading actions from file: <%s>, which exists: <%s>' %
            (_filepath, file.does_file_exist(_filepath)))

        actions_elem = ET.parse(open(_filepath, "r")).getroot()
        for elem in actions_elem.getchildren():
            if elem.tag == '{0}action'.format(NAMESPACE):
                self._xoze.actions.append(self._load_action(elem))
            elif elem.tag == '{0}service'.format(NAMESPACE):
                self._xoze.services.append(self._load_service(elem))
            elif elem.tag == '{0}view'.format(NAMESPACE):
                self._xoze.views.append(self._load_view(elem))
            else:
                logging.getLogger().error('found UNKNOWN tag: <%s>' % (elem))
コード例 #12
0
ファイル: context.py プロジェクト: noba3/KoTos
 def __initialize__(self, context):
     snapper_filepath = file.resolve_file_path(
         context.get_addon_path(),
         extraDirPath='xoze/snapvideo',
         filename='snappers.xml',
         makeDirs=False)
     self._snappers = []
     logging.getLogger().debug('Loading snappers.xml from path... ' +
                               snapper_filepath)
     actions_elem = ET.parse(open(snapper_filepath, "r")).getroot()
     for elem in actions_elem.getchildren():
         if elem.tag == '{0}snapper'.format(NAMESPACE_SNAPPER):
             if elem.attrib.has_key(
                     'enabled') and elem.attrib['enabled'] == 'true':
                 self._snappers.append(
                     Snapper(elem, context.get_addon_path()))
         else:
             logging.getLogger().error('found UNKNOWN tag: <%s>' % (elem))
コード例 #13
0
ファイル: dtb_actions.py プロジェクト: RozebMomin/KodiAddons
def check_cache(req_attrib, modelMap):
    logging.getLogger().debug('DTB - Check cache ***********************')
    logging.getLogger().debug(req_attrib)
    refresh_cache = True
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Channels.json', makeDirs=True)
    refresh = context.get_addon().getSetting('dtbForceRefresh')
    if refresh == None or refresh != 'true':
        modified_time = file.get_last_modified_time(filepath)
        if modified_time is not None:
            diff = long((time.time() - modified_time) / 3600)
            if diff < 720:
                refresh_cache = False
            else:
                logging.getLogger().debug('DTB_Channels.json was last created 30 days ago, refreshing data.')
    else:
        logging.getLogger().debug('Request to force refresh.')
    modelMap['refresh_cache'] = refresh_cache
    modelMap['cache_filepath'] = filepath
コード例 #14
0
ファイル: dr_actions.py プロジェクト: zuberv/xceltv
def load_favorite_tv_shows(req_attrib, modelMap):
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DR_Favorites.json', makeDirs=False)
    logging.getLogger().debug('loading favorite tv shows from file : %s' % filepath)
    favorite_tv_shows = _read_favorite_tv_shows_cache_(filepath)
    if favorite_tv_shows is None:
        return
    favorite_tv_shows_items = []
    for tv_show_name in favorite_tv_shows:
        favorite_tv_show = favorite_tv_shows[tv_show_name]
        item = xbmcgui.ListItem(label=tv_show_name, iconImage=favorite_tv_show['tv-show-thumb'], thumbnailImage=favorite_tv_show['tv-show-thumb'])
        item.setProperty('channel-type', favorite_tv_show['channel-type'])
        item.setProperty('channel-name', favorite_tv_show['channel-name'])
        item.setProperty('tv-show-name', tv_show_name)
        item.setProperty('tv-show-url', favorite_tv_show['tv-show-url'])
        item.setProperty('tv-show-thumb', favorite_tv_show['tv-show-thumb'])
        favorite_tv_shows_items.append(item)
        
    modelMap['favorite_tv_shows_items'] = favorite_tv_shows_items
コード例 #15
0
def watch_live(req_attrib, modelMap):
    channel_name = req_attrib['channel-name']

    live_filepath = file.resolve_file_path(
        AddonContext().get_addon_data_path(),
        extraDirPath='data',
        filename='Live.json',
        makeDirs=True)
    live_file_channels = _read_live_tv_channels_cache_(live_filepath)
    tv_channel = None
    if LIVE_CHANNELS.has_key(channel_name):
        tv_channel = LIVE_CHANNELS[channel_name]
    if live_file_channels is not None and live_file_channels.has_key(
            channel_name):
        tv_channel = live_file_channels[channel_name]

    item = xbmcgui.ListItem(label=channel_name,
                            iconImage=tv_channel['iconimage'],
                            thumbnailImage=tv_channel['iconimage'])
    item.setProperty('streamLink', tv_channel['channelUrl'])
    modelMap['live_item'] = item
コード例 #16
0
def remove_favorite(req_attrib, modelMap):
    logging.getLogger().debug('remove tv show favorite...')
    favorite = CacheManager().get('dtb_selected_favorite')
    favorite_thumb = CacheManager().get('dtb_selected_favorite_thumb')
    favorites = CacheManager().get('dtb_tv_favorites')
    if favorites is None:
        favorites = {}
    elif favorites.has_key(favorite):
        favorites.pop(favorite)

    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(),
                                      extraDirPath='data',
                                      filename='DTB_Favorites.json',
                                      makeDirs=False)
    logging.getLogger().debug(favorites)
    _write_favorite_tv_shows_cache_(filepath, favorites)

    notification = "XBMC.Notification(%s,%s,%s,%s)" % (
        favorite, 'REMOVED FAVORITE', 2500, favorite_thumb)
    xbmc.executebuiltin(notification)

    modelMap['reload_favorite_tv_shows_items'] = True
    if len(favorites) > 0:
        favorite_tv_shows_items = []
        for tv_show_name in favorites:
            favorite_tv_show = favorites[tv_show_name]
            item = xbmcgui.ListItem(
                label=tv_show_name,
                iconImage=favorite_tv_show['tv-show-thumb'],
                thumbnailImage=favorite_tv_show['tv-show-thumb'])
            item.setProperty('channel-type', favorite_tv_show['channel-type'])
            item.setProperty('channel-name', favorite_tv_show['channel-name'])
            item.setProperty('tv-show-name', tv_show_name)
            item.setProperty('tv-show-url', favorite_tv_show['tv-show-url'])
            item.setProperty('tv-show-thumb',
                             favorite_tv_show['tv-show-thumb'])
            favorite_tv_shows_items.append(item)

        modelMap['favorite_tv_shows_items'] = favorite_tv_shows_items
コード例 #17
0
ファイル: dtf_actions.py プロジェクト: noba3/KoTos
def check_cache(req_attrib, modelMap):
    logging.getLogger().debug("Check cache for DTF ***********************")
    logging.getLogger().debug(req_attrib)
    refresh_cache = True
    context = AddonContext()
    filepath = file.resolve_file_path(
        context.get_addon_data_path(), extraDirPath="data", filename="DTF_Channels.json", makeDirs=True
    )
    logging.getLogger().debug(filepath)
    refresh = context.get_addon().getSetting("dtfForceRefresh")
    if refresh == None or refresh != "true":
        modified_time = file.get_last_modified_time(filepath)
        if modified_time is not None:
            diff = long((time.time() - modified_time) / 3600)
            if diff < 720:
                refresh_cache = False
            else:
                logging.getLogger().debug("DTF_Channels.json was last created 30 days ago, refreshing data.")
    else:
        logging.getLogger().debug("Request to force refresh.")
    modelMap["refresh_cache"] = refresh_cache
    modelMap["cache_filepath"] = filepath
コード例 #18
0
ファイル: dtb_actions.py プロジェクト: RozebMomin/KodiAddons
def add_tv_show_favorite(req_attrib, modelMap):
    logging.getLogger().debug('add tv show favorite...')
    tv_show_url = req_attrib['tv-show-url']
    tv_show_name = req_attrib['tv-show-name']
    tv_show_thumb = req_attrib['tv-show-thumb']
    channel_type = req_attrib['channel-type']
    channel_name = req_attrib['channel-name']
    logging.getLogger().debug('add tv show favorite...' + tv_show_url)
    
    favorites = CacheManager().get('dtb_tv_favorites')
    if favorites is None:
        favorites = {}
    elif favorites.has_key(tv_show_name):
        favorites.pop(tv_show_name)
    
    favorites[tv_show_name] = {'tv-show-name':tv_show_name, 'tv-show-thumb':tv_show_thumb, 'tv-show-url':tv_show_url, 'channel-name':channel_name, 'channel-type':channel_type}
    context = AddonContext()
    filepath = file.resolve_file_path(context.get_addon_data_path(), extraDirPath='data', filename='DTB_Favorites.json', makeDirs=False)
    logging.getLogger().debug(favorites)
    _write_favorite_tv_shows_cache_(filepath, favorites)
    
    notification = "XBMC.Notification(%s,%s,%s,%s)" % (tv_show_name, 'ADDED TO FAVORITES', 2500, tv_show_thumb)
    xbmc.executebuiltin(notification)
コード例 #19
0
def load_channels(req_attrib, modelMap):
    logging.getLogger().debug('load channels...')
    tv_channels = _read_tv_channels_cache_(
        modelMap['cache_filepath'])['channels']

    tv_channel_items = []
    live_tv_channel_items = []

    display_channel_type = 1

    live_channels_all = {}
    live_channels_all.update(LIVE_CHANNELS)

    live_filepath = file.resolve_file_path(
        AddonContext().get_addon_data_path(),
        extraDirPath='data',
        filename='Live.json',
        makeDirs=True)
    live_file_channels = _read_live_tv_channels_cache_(live_filepath)
    if live_file_channels is not None:
        live_channels_all.update(live_file_channels)

    channel_names = live_channels_all.keys()
    channel_names.sort()
    for channel_name in channel_names:
        channel_obj = live_channels_all[channel_name]
        if ((display_channel_type == 1
             and channel_obj['channelType'] == CHANNEL_TYPE_IND)
                or (display_channel_type == 0)):
            item = xbmcgui.ListItem(label=channel_name,
                                    iconImage=channel_obj['iconimage'],
                                    thumbnailImage=channel_obj['iconimage'])
            item.setProperty('channel-name', channel_name)
            item.setProperty('live-link', 'true')
            item.setProperty('direct-link', 'false')
            live_tv_channel_items.append(item)

    for channel_name in DIRECT_CHANNELS:
        channel_obj = DIRECT_CHANNELS[channel_name]
        if ((display_channel_type == 1
             and channel_obj['channelType'] == CHANNEL_TYPE_IND)
                or (display_channel_type == 0)):
            item = xbmcgui.ListItem(label=channel_name,
                                    iconImage=channel_obj['iconimage'],
                                    thumbnailImage=channel_obj['iconimage'])
            item.setProperty('channel-name', channel_name)
            item.setProperty('direct-link', 'true')
            item.setProperty('live-link', 'false')
            tv_channel_items.append(item)

    channel_names = tv_channels.keys()
    channel_names.sort()
    for channel_name in channel_names:
        channel_obj = tv_channels[channel_name]
        if ((display_channel_type == 1
             and channel_obj['channelType'] == CHANNEL_TYPE_IND)
                or (display_channel_type == 2
                    and channel_obj['channelType'] == CHANNEL_TYPE_PAK)
                or (display_channel_type == 0)):

            item = xbmcgui.ListItem(label=channel_name,
                                    iconImage=channel_obj['iconimage'],
                                    thumbnailImage=channel_obj['iconimage'])
            item.setProperty('channel-name', channel_name)
            item.setProperty('direct-link', 'false')
            item.setProperty('live-link', 'false')
            tv_channel_items.append(item)

    modelMap['tv_channel_items'] = tv_channel_items
    modelMap['live_tv_channel_items'] = live_tv_channel_items