コード例 #1
0
def download(id, url, filename, search_string=""):
    subtitle_list = []
    exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass"]

    ## 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")
    req = urllib2.Request(url, headers={"User-Agent": "Kodi-Addon"})
    sub = urllib2.urlopen(req).read()
    with open(filename, "wb") as subFile:
        subFile.write(sub)
    subFile.close()

    xbmc.sleep(500)
    xbmc.executebuiltin(
        (
            'XBMC.Extract("%s","%s")' % (filename, __temp__,)
        ).encode('utf-8'), True)

    for file in xbmcvfs.listdir(__temp__)[1]:
        file = os.path.join(__temp__, file)
        if os.path.splitext(file)[1] in exts:
            if search_string and string.find(
                string.lower(file),
                string.lower(search_string)
            ) == -1:
                continue
            log(__name__, "=== returning subtitle file %s" % file)
            subtitle_list.append(file)

    return subtitle_list
コード例 #2
0
def download(id, url, filename, search_string=""):
    subtitle_list = []
    exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass"]

    ## 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")
    req = urllib2.Request(url, headers={"User-Agent": "Kodi-Addon"})
    sub = urllib2.urlopen(req).read()
    with open(filename, "wb") as subFile:
        subFile.write(sub)
    subFile.close()

    xbmc.sleep(500)
    xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (
        filename,
        __temp__,
    )).encode('utf-8'), True)

    for file in xbmcvfs.listdir(__temp__)[1]:
        file = os.path.join(__temp__, file)
        if os.path.splitext(file)[1] in exts:
            if search_string and string.find(
                    string.lower(file), string.lower(search_string)) == -1:
                continue
            log(__name__, "=== returning subtitle file %s" % file)
            subtitle_list.append(file)

    return subtitle_list
コード例 #3
0
def search_common(content):
    if content is not None:
        log(__name__, "Resultados encontrados...")
        #object_subtitles = find_subtitles(content)
        items = []
        result = json.loads(content)

        if "releases" in result:
            for release in result['releases']:
                for subtitle in release['subtitles']:
                    item = {}
                    item['lang'] = "Spanish"
                    item['filename'] = urllib.unquote_plus(
                        subtitle['uri'].split("/")[-1])
                    item['rating'] = str(subtitle['count'])
                    item['image'] = 'es'
                    item['id'] = subtitle['uri'].split("/")[-2]
                    item['link'] = subtitle['uri']

                    #Check for Closed Caption
                    if "-CC" in item['filename']:
                        item['hearing_imp'] = True
                    else:
                        item['hearing_imp'] = False

                    items.append(item)

        return items
コード例 #4
0
def search_filename(filename, languages):
    title, year = xbmc.getCleanMovieTitle(filename)
    log(__name__, "clean title: \"%s\" (%s)" % (title, year))
    try:
        yearval = int(year)
    except ValueError:
        yearval = 0
    if title and yearval > 1900:
        search_string = title + "+" + year
        search_argenteam_api(search_string)
    else:
        match = re.search(
            r'\WS(?P<season>\d\d)E(?P<episode>\d\d)',
            title,
            flags=re.IGNORECASE
        )
        if match is not None:
            tvshow = string.strip(title[:match.start('season')-1])
            season = string.lstrip(match.group('season'), '0')
            episode = string.lstrip(match.group('episode'), '0')
            search_string = "%s S%#02dE%#02d" % (
                tvshow,
                int(season),
                int(episode)
            )
            search_argenteam_api(search_string)
        else:
            search_argenteam_api(filename)
コード例 #5
0
def search_filename(filename, languages):
    title, year = xbmc.getCleanMovieTitle(filename)
    log(__name__, "clean title: \"%s\" (%s)" % (title, year))
    try:
        yearval = int(year)
    except ValueError:
        yearval = 0
    if title and yearval > 1900:
        search_string = title + "+" + year
        search_argenteam_api(search_string)
    else:
        match = re.search(
            r'\WS(?P<season>\d\d)E(?P<episode>\d\d)',
            title,
            flags=re.IGNORECASE
        )
        if match is not None:
            tvshow = title[:match.start('season') - 1].strip()
            season = match.group('season').lstrip('0')
            episode = match.group('episode').lstrip('0')
            search_string = "%s S%#02dE%#02d" % (
                tvshow,
                int(season),
                int(episode)
            )
            search_argenteam_api(search_string)
        else:
            search_argenteam_api(filename)
コード例 #6
0
def search_common(content):
    if content is not None:
        log(__name__, "Resultados encontrados...")
        #object_subtitles = find_subtitles(content)
        items = []
        result = json.loads(content)

        if "releases" in result:
            for release in result['releases']:
                for subtitle in release['subtitles']:
                    item = {}
                    item['lang'] = "Spanish"
                    item['filename'] = urllib.unquote_plus(
                        subtitle['uri'].split("/")[-1]
                    )
                    item['rating'] = str(subtitle['count'])
                    item['image'] = 'es'
                    item['id'] = subtitle['uri'].split("/")[-2]
                    item['link'] = subtitle['uri']

                    #Check for Closed Caption
                    if "-CC" in item['filename']:
                        item['hearing_imp'] = True
                    else:
                        item['hearing_imp'] = False

                    items.append(item)

        return items
コード例 #7
0
def search_tvshow(tvshow, season, episode, title, languages, filename):
    tvshow = string.strip(tvshow)

    #Prevent that the "US" acronym interfere with the search in the site
    tvshow = tvshow.replace("(US)","")

    search_string = "%s S%#02dE%#02d %s" % (tvshow, int(season), int(episode), title)

    log(__name__, "Search tvshow = %s" % search_string)
    search_pack(search_string)
コード例 #8
0
def search(item):
    filename = os.path.splitext(os.path.basename(item['file_original_path']))[0]
    log(__name__, "Search_argenteam='%s', filename='%s', addon_version=%s" % (item, filename, __version__))

    if item['mansearch']:
        search_manual(item['mansearchstr'], item['3let_language'], filename)
    elif item['tvshow']:
        search_tvshow(item['tvshow'], item['season'], item['episode'], item['title'], item['3let_language'], filename)
    elif item['title'] and item['year']:
        search_movie(item['title'], item['year'], item['3let_language'], filename)
    else:
        search_filename(filename, item['3let_language'])
コード例 #9
0
def find_movie(content, title, year):
    url_found = None
    h = HTMLParser.HTMLParser()
    for matches in re.finditer(movie_season_pattern, content, re.IGNORECASE | re.DOTALL):
        found_title = matches.group('title')
        found_title = h.unescape(found_title)
        log(__name__, "Found movie on search page: %s (%s)" % (found_title, matches.group('year')))
        if string.find(string.lower(found_title), string.lower(title)) > -1:
            if matches.group('year') == year:
                log(__name__, "Matching movie found on search page: %s (%s)" % (found_title, matches.group('year')))
                url_found = matches.group('link')
                break
    return url_found
コード例 #10
0
def find_subtitles(content):
    #url_found = None
    possible_matches = []
    #ll_tvshows = []

    h = HTMLParser.HTMLParser()
    for matches in re.finditer(subtitle_pattern, content, re.IGNORECASE | re.DOTALL | re.UNICODE):
        id = matches.group(6)
        filename=urllib.unquote_plus(matches.group(7))
        downloads = (int(matches.group(2)) / 1000) / 2
        log(__name__, "Encontrado subtitulo: %s" % filename)
        possible_matches.append({'id':id, 'filename':filename,'downloads':downloads})

    return possible_matches
コード例 #11
0
def search_filename(filename, languages):
    title, year = xbmc.getCleanMovieTitle(filename)
    log(__name__, "clean title: \"%s\" (%s)" % (title, year))
    try:
        yearval = int(year)
    except ValueError:
        yearval = 0
    if title and yearval > 1900:
        search_movie(title, year, item['3let_language'], filename)
    else:
        match = re.search(r'\WS(?P<season>\d\d)E(?P<episode>\d\d)', title, flags=re.IGNORECASE)
        if match is not None:
            tvshow = string.strip(title[:match.start('season')-1])
            season = string.lstrip(match.group('season'), '0')
            episode = string.lstrip(match.group('episode'), '0')
            search_tvshow(tvshow, season, episode, '', item['3let_language'], filename)
        else:
            search_manual(filename, item['3let_language'], filename)
コード例 #12
0
def search(item):
    filename = os.path.splitext(os.path.basename(
        item['file_original_path']))[0]
    log(
        __name__, "Search_argenteam='%s', filename='%s', addon_version=%s" %
        (item, filename, __version__))

    if item['mansearch']:
        search_string = urllib.unquote(item['mansearchstr'])
        search_argenteam_api(search_string)
    elif item['tvshow']:
        search_string = "%s S%#02dE%#02d" % (item['tvshow'].replace(
            "(US)", ""), int(item['season']), int(item['episode']))
        search_argenteam_api(search_string)
    elif item['title'] and item['year']:
        search_string = item['title'] + " " + item['year']
        search_argenteam_api(search_string)
    else:
        search_filename(filename, item['3let_language'])
コード例 #13
0
def search_common(content):
    if content is not None:
        log(__name__, "Resultados encontrados...")
        object_subtitles = find_subtitles(content)
        items = []
        if object_subtitles is not None:
            log(__name__, "Buscando subtitulos...")
            
            for sub in object_subtitles:
                item = {}
                item['lang'] = "Spanish"
                item['filename'] = sub['filename']
                item['rating'] = str(sub['downloads'])
                item['image'] = 'es'
                item['id'] = sub['id']
                item['link'] = main_url + "subtitles/" + sub['id'] + "/" + sub['filename']
                items.append(item)
        
        return items
コード例 #14
0
def search(item):
    filename = os.path.splitext(os.path.basename(item['file_original_path']))[0]
    log(__name__, "Search_argenteam='%s', filename='%s', addon_version=%s" % (
        item,
        filename,
        __version__)
    )

    if item['mansearch']:
        search_string = urllib.unquote(item['mansearchstr'])
        search_argenteam_api(search_string)
    elif item['tvshow']:
        search_string = "%s S%#02dE%#02d" % (
            item['tvshow'].replace("(US)", ""),
            int(item['season']),
            int(item['episode'])
        )
        search_argenteam_api(search_string)
    elif item['title'] and item['year']:
        search_string = item['title'] + " " + item['year']
        search_argenteam_api(search_string)
    else:
        search_filename(filename, item['3let_language'])
コード例 #15
0
def search_movie(title, year, languages, filename):
    title = string.strip(title)

    log(__name__, "Search movie = %s" % title)
    search_string = "%s (%s)" % (title, year)
    search_pack(search_string)