def Search(item):
    d = timeout(set_filehash, args=(item["file_original_path"], item["rar"]), timeout_duration=15)
    md5hash = d.hexdigest()
    t = f(md5hash)
    filename = '.'.join(os.path.basename(item["file_original_path"]).split(".")[:-1])
    helper = NapiProjektHelper(filename, md5hash)
    results = helper.search(item, t)

    for result in results:
        listitem = xbmcgui.ListItem(label=xbmc.convertLanguage(result["language"], xbmc.ENGLISH_NAME),
                                    # language name for the found subtitle
                                    label2=filename,  # file name for the found subtitle
                                    iconImage="5",  # rating for the subtitle, string 0-5
                                    thumbnailImage=xbmc.convertLanguage(result["language"], xbmc.ISO_639_1)
                                    # language flag, ISO_639_1 language + gif extention, e.g - "en.gif"
                                    )
        listitem.setProperty("sync", '{0}'.format("true").lower())  # set to "true" if subtitle is matched by hash,
        # indicates that sub is 100 Comaptible
        listitem.setProperty("hearing_imp",
                             '{0}'.format("false").lower())  # set to "true" if subtitle is for hearing impared

        ## below arguments are optional, it can be used to pass any info needed in download function
        ## anything after "action=download&" will be sent to addon once user clicks listed subtitle to download
        url = "plugin://%s/?action=download&l=%s&f=%s&filename=%s" % (
            __scriptid__, result["language"], md5hash, filename)
        ## add it to list, this can be done as many times as needed for all subtitles found
        xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False)
def Download(language, hash, filename):
    subtitle_list = []
    ## Cleanup temp dir, we recomend you download/unzip your subs in temp folder and
    ## pass that to XBMC to copy and activate
    if xbmcvfs.exists(__temp__):
        shutil.rmtree(__temp__)
    xbmcvfs.mkdirs(__temp__)

    filename = os.path.join(__temp__, filename + ".zip")
    napiHelper = NapiProjektHelper(filename, hash)
    filename = napiHelper.download(language)
    subtitle_list.append(filename)  # this can be url, local path or network path.

    return subtitle_list