Beispiel #1
0
def search(item):
    best_match_id = None
    downloader = TorecSubtitlesDownloader()

    try:
        search_string = build_search_string(item)
        search_data = downloader.getSubtitleMetaData(search_string)

        log(__name__, "search_data=%s" % str(search_data))
        if search_data != None:
            best_match_id = downloader.getBestMatchID(
                os.path.basename(item['file_original_path']), search_data)
    except:
        log(__name__, "failed to connect to service for subtitle search")
        xbmc.executebuiltin(
            (u'Notification(%s,%s)' %
             (__scriptname__, __language__(32001))).encode('utf-8'))
        return

    list_items = []
    if search_data != None:
        for item_data in search_data.options:
            listitem = xbmcgui.ListItem(
                label="Hebrew",
                label2=item_data.name,
                iconImage="0",
                thumbnailImage="he",
            )

            url = "plugin://%s/?action=download&page_id=%s&subtitle_id=%s&filename=%s" % (
                __scriptid__, search_data.id, item_data.id, item_data.name)

            if best_match_id != None and item_data.id == best_match_id:
                listitem.setProperty("sync", "true")
                list_items.insert(0, (
                    url,
                    listitem,
                    False,
                ))
            else:
                list_items.append((
                    url,
                    listitem,
                    False,
                ))

    xbmcplugin.addDirectoryItems(handle=int(sys.argv[1]), items=list_items)
def search(item):
    best_match_id = None
    downloader = TorecSubtitlesDownloader()
    
    try:
        search_string = build_search_string(item)
        search_data = downloader.getSubtitleMetaData(search_string)
        
        log(__name__, "search_data=%s" % str(search_data))
        if search_data != None:
            best_match_id = downloader.getBestMatchID(os.path.basename(item['file_original_path']), search_data)
    except:
        log( __name__, "failed to connect to service for subtitle search")
        xbmc.executebuiltin((u'Notification(%s,%s)' % (__scriptname__ , __language__(32001))).encode('utf-8'))
        return
    
    list_items = []
    if search_data != None:
        for item_data in search_data.options:
            listitem = xbmcgui.ListItem(label    = "Hebrew",
                                  label2         = item_data.name,
                                  iconImage      = "0",
                                  thumbnailImage = "he",
                                  )
                                  

            url = "plugin://%s/?action=download&page_id=%s&subtitle_id=%s&filename=%s" % (__scriptid__,
                                                                        search_data.id,
                                                                        item_data.id,
                                                                        item_data.name
                                                                        )

            if best_match_id != None and item_data.id == best_match_id:
                listitem.setProperty("sync", "true")
                list_items.insert(0, (url, listitem, False,))
            else:
                list_items.append((url, listitem, False,))
    
    xbmcplugin.addDirectoryItems(handle=int(sys.argv[1]), items=list_items)