示例#1
0
文件: create.py 项目: kiliantv/repo
def getTVShowFromList(showList, strm_name='', strm_type='Other'):
    pagesDone = 0
    file = ''

    while pagesDone < int(PAGINGTVshows):
        strm_type = strm_type.replace('Shows-Collection', 'TV-Shows')
        try:
            for detailInfo in showList:
                detailInfo = stringUtils.removeHTMLTAGS(detailInfo)
                filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
                if filetypes:
                    filetype = filetypes.group(1)
                    files = re.search('"file" *: *"(.*?)",', detailInfo)
                    episodes = re.search('"episode" *: *(.*?),', detailInfo)
                    seasons = re.search('"season" *: *(.*?),', detailInfo)
                    showtitles = re.search('"showtitle" *: *"(.*?)",',
                                           detailInfo)
                    labels = re.search('"label" *: *"(.*?)",', detailInfo)

                    if labels:
                        label = str(labels.group(1).lstrip().rstrip())
                    else:
                        label = "None"

                    if showtitles:
                        showtitle = str(showtitles.group(1).lstrip().rstrip())
                    else:
                        label = "None"

                    if not fileSys.isInMediaList(
                            label, strm_type
                    ) and label != "" and label != ">>>" and label != "None" and files.group(
                            1).find("playMode=play") == "-1":
                        fileSys.writeMediaList(
                            files.group(1).lstrip().rstrip(), label, strm_type)

                    if files and filetype != 'file' and label != ">>>":
                        addTVShows(stringUtils.uni(
                            jsonUtils.requestList(files.group(1), 'video')),
                                   strm_name="",
                                   strm_type=strm_type)
                    else:
                        if showtitles and seasons == "-1" and episodes == "-1":
                            xbmc.executebuiltin(
                                'Notification(%s, %s, %d, %s)' %
                                (ADDON_NAME, "ShowsList", 1000, ""))
                            getEpisodes(
                                stringUtils.uni(
                                    jsonUtils.requestList(
                                        files.group(1), 'video')),
                                strm_name.strip(), strm_type)

        except IOError as (errno, strerror):
            print("I/O error({0}): {1}").format(errno, strerror)
        except ValueError:
            print("No valid integer in line.")
示例#2
0
def update(strm_name, url, media_type, thelist):
    plex_details = stringUtils.uni(
        jsonUtils.requestList("plugin://plugin.video.plexbmc", media_type))
    for plex_detail in plex_details:
        plex_detail = stringUtils.removeHTMLTAGS(plex_detail)
        label = re.search('"label" *: *"(.*?)",', plex_detail)
        if label and strm_name.replace(
                '++RenamedTitle++', '') == stringUtils.cleanByDictReplacements(
                    label.group(1)):
            serverurl = re.search('"file" *: *"(.*?)",', plex_detail).group(1)
            if url != serverurl:
                for entry in thelist:
                    if entry.split("|")[1] == strm_name:
                        newentry = '|'.join([
                            entry.split("|")[0],
                            entry.split("|")[1].decode("utf-8"), serverurl
                        ]) + '\n'
                        thelist = stringUtils.replaceStringElem(
                            thelist, entry, newentry)
                        thefile = xbmc.translatePath(
                            os.path.join(profile, 'MediaList.xml'))
                        with open(thefile.decode("utf-8"), 'w') as output_file:
                            for linje in thelist:
                                if not linje.startswith('\n'):
                                    output_file.write(
                                        linje.strip().encode('utf-8') + '\n')
                                else:
                                    output_file.write(linje.strip())
                        break
                url = serverurl
    return url
示例#3
0
文件: create.py 项目: kiliantv/repo
def addTVShows(contentList, strm_name='', strm_type='Other'):
    showsList = []
    showtitle = strm_name
    pagesDone = 0
    sectiveContent = contentList
    #     while pagesDone < int(PAGINGTVshows):
    j = 100 / len(contentList)

    for detailInfo in contentList:
        detailInfo = stringUtils.removeHTMLTAGS(detailInfo)
        filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
        showtitles = re.search('"showtitle" *: *"(.*?)",', detailInfo)
        if showtitles:
            showtitle = showtitles.group(1)
        try:
            if filetypes:
                filetype = filetypes.group(1)
                files = re.search('"file" *: *"(.*?)",', detailInfo)

                if filetype != 'file':
                    getEpisodes(
                        stringUtils.uni(
                            jsonUtils.requestList(files.group(1), 'video')),
                        strm_name.strip(), strm_type, j)
                else:
                    getEpisodes(detailInfo, strm_name, strm_type, j)
                thisDialog.dialogeBG.update(j, showtitle)
                j = j + 100 / len(contentList)
        except IOError as (errno, strerror):
            print("I/O error({0}): {1}").format(errno, strerror)
        except ValueError:
            print("No valid integer in line.")
示例#4
0
文件: create.py 项目: kodinerds/repo
def addTVShows(contentList, strm_name="", strm_type="Other"):
    showsList = []
    showtitle = strm_name
    pagesDone = 0
    sectiveContent = contentList

    #     while pagesDone < int(PAGINGTVshows):
    for detailInfo in contentList:
        filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)

        if filetypes:
            filetype = filetypes.group(1)
            files = re.search('"file" *: *"(.*?)",', detailInfo)

            if filetype != "file":
                getEpisodes(stringUtils.uni(jsonUtils.requestList(files.group(1), "video")), strm_name, strm_type)
            else:
                getEpisodes(detailInfo, strm_name, strm_type)
    #         pagesDone += 1
    #
    #         if filetype != 'file' and pagesDone < int(PAGINGMovies) and is_multi:
    #             contentList = stringUtils.uni(jsonUtils.requestList(files.group(1), 'video'))
    #         else:
    #             pagesDone = int(PAGINGMovies)
    return showsList
示例#5
0
def sendJSON(command):
    data = ''
    try:
        data = xbmc.executeJSONRPC(stringUtils.uni(command))
    except UnicodeEncodeError:
        data = xbmc.executeJSONRPC(stringUtils.asciis(command))
    return data.decode('utf-8') #uni(data)
def sendJSON(command):
    data = ''
    try:
        data = xbmc.executeJSONRPC(stringUtils.uni(command))
    except UnicodeEncodeError:
        data = xbmc.executeJSONRPC(stringUtils.asciis(command))
    return json.loads(data.decode('utf-8')).get('result', {})
示例#7
0
def sendJSON(command):
    data = ''
    try:
        data = xbmc.executeJSONRPC(stringUtils.uni(command))
    except UnicodeEncodeError:
        data = xbmc.executeJSONRPC(stringUtils.asciis(command))
    return data.decode('utf-8') #uni(data)
示例#8
0
文件: jsonUtils.py 项目: smplgd/repo
def requestItem(file, fletype='video'):
    utils.addon_log("requestItem")  #
    if file.find("playMode=play") == -1:
        detail = stringUtils.uni(requestList(file, fletype))
        return detail
    json_query = (
        '{"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":1,"properties":["thumbnail","fanart","title","year","mpaa","imdbnumber","description","season","episode","playcount","genre","duration","runtime","showtitle","album","artist","plot","plotoutline","tagline","tvshowid"]}, "id": 1}'
    )
    json_folder_detail = sendJSON(json_query)
    return re.compile("{(.*?)}", re.DOTALL).findall(json_folder_detail)
示例#9
0
文件: create.py 项目: kodinerds/repo
def getTVShowFromList(showList, strm_name="", strm_type="Other"):
    strm_type = strm_type.replace("Shows-Collection", "TV-Shows")
    for detailInfo in showList:
        filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
        if filetypes:
            filetype = filetypes.group(1)
            files = re.search('"file" *: *"(.*?)",', detailInfo)
            episodes = re.search('"episode" *: *(.*?),', detailInfo)
            seasons = re.search('"season" *: *(.*?),', detailInfo)
            showtitles = re.search('"showtitle" *: *"(.*?)",', detailInfo)

            if filetype != "file":
                if showtitles and seasons == "-1" and episodes == "-1":
                    getEpisodes(stringUtils.uni(jsonUtils.requestList(files.group(1), "video")), strm_name, strm_type)
                else:
                    addTVShows(
                        stringUtils.uni(jsonUtils.requestList(files.group(1), "video")),
                        strm_name="",
                        strm_type=strm_type,
                    )
示例#10
0
文件: jsonUtils.py 项目: smplgd/repo
def requestList(path, fletype='video'):
    if path.find("playMode=play") != -1:
        detail = stringUtils.uni(requestItem(path, fletype))
        return detail

    utils.addon_log("requestList, path = " + path)
    json_query = (
        '{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "properties":["thumbnail","fanart","title","year","track","mpaa","imdbnumber","description","season","episode","playcount","genre","duration","runtime","showtitle","album","artist","plot","plotoutline","tagline","tvshowid"]}, "id": 1}'
        % (path, fletype))
    json_folder_detail = sendJSON(json_query)
    return re.compile("{(.*?)}", re.DOTALL).findall(json_folder_detail)
示例#11
0
def addLink(name,
            url,
            mode,
            art,
            plot,
            genre,
            date,
            showcontext,
            playlist,
            regexs,
            total,
            setCookie=""):
    utils.addon_log('addLink')
    u = sys.argv[0] + "?url=" + urllib.quote_plus(stringUtils.uni(
        url)) + "&mode=" + str(mode) + "&name=" + urllib.quote_plus(
            stringUtils.uni(name)) + "&fanart=" + urllib.quote_plus(
                art.get('fanart', ''))
    contextMenu = []
    thumbArt = art.get('thumb', None)
    if thumbArt == None:
        thumbArt = art.get('fanart', None)
    liz = xbmcgui.ListItem(name, iconImage=thumbArt, thumbnailImage=thumbArt)
    liz.setInfo(type="Video",
                infoLabels={
                    "Title": name,
                    "Plot": plot,
                    "Genre": genre,
                    "dateadded": date
                })
    liz.setArt(art)
    liz.setProperty('IsPlayable', 'true')
    contextMenu.append(
        ('Create Strm',
         'XBMC.RunPlugin(%s&mode=200&name=%s&filetype=file)' % (u, name)))
    liz.addContextMenuItems(contextMenu)
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')

    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                url=u,
                                listitem=liz,
                                totalItems=total)
示例#12
0
def addDir(name, url, mode, art, plot, genre, date, credits, showcontext=False):
    utils.addon_log('addDir')
    u = "%s?url=%s&name=%s&fanart=%s" % (sys.argv[0], urllib.quote_plus(stringUtils.uni(url)), urllib.quote_plus(stringUtils.cleanLabels(stringUtils.uni(name))), urllib.quote_plus(art.get('fanart', '')))
    contextMenu = []
    thumbArt = art.get('thumb', None)
    if thumbArt == None:
        thumbArt = art.get('fanart', None)
    liz = xbmcgui.ListItem(name, iconImage=thumbArt, thumbnailImage=thumbArt)
    liz.setInfo(type="Video", infoLabels={ "Title": name, "Plot": plot, "Genre": genre, "dateadded": date, "credits": credits })
    liz.setArt(art)
    contextMenu.append(('Create Strms', 'XBMC.RunPlugin(%s&mode=%d)' % (u, 200)))
    liz.addContextMenuItems(contextMenu)

    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url='%s&mode=%d' % (u, mode), listitem=liz, isFolder=True)
示例#13
0
文件: create.py 项目: kiliantv/repo
def addTVShowsSST(contentList, strm_name='', strm_type='Other'):
    showsList = []
    showtitle = strm_name
    pagesDone = 0
    sectiveContent = contentList
    #     while pagesDone < int(PAGINGTVshows):
    for detailInfo in contentList:
        detailInfo = stringUtils.removeHTMLTAGS(detailInfo)
        filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
        try:
            if filetypes:
                filetype = filetypes.group(1)
                files = re.search('"file" *: *"(.*?)",', detailInfo)
                if filetype != 'file':
                    contentListSub = stringUtils.uni(
                        jsonUtils.requestList(files.group(1), 'video'))
                    for detailInfo in contentListSub:
                        while filetype != "file":
                            detailInfo = stringUtils.removeHTMLTAGS(detailInfo)
                            filetypes = re.search('"filetype" *: *"(.*?)",',
                                                  detailInfo)

                            if filetype != 'file':
                                detailInfo = stringUtils.uni(
                                    jsonUtils.requestList(
                                        files.group(1), 'video'))
                            else:
                                getEpisodes(stringUtils.uni(detailInfo),
                                            strm_name.strip(), strm_type)

                            getEpisodes(stringUtils.uni(detailInfo),
                                        strm_name.strip(), strm_type)

        except IOError as (errno, strerror):
            print("I/O error({0}): {1}").format(errno, strerror)
        except ValueError:
            print("No valid integer in line.")
示例#14
0
def markMovie(sTitle):
    if xbmc.getCondVisibility('Library.HasContent(Movies)'):
        try:
            print("Check if movie exists in library when marking as watched")
            meta = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"field": "playcount", "operator": "is", "value": "0"}, "limits": { "start" : 0, "end": 75 }, "properties" : ["art", "rating", "thumbnail", "playcount", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}')  
            meta = stringUtils.uni(meta)#(meta, 'utf-8', errors='ignore')
            meta = json.loads(meta)
            meta = meta['result']['movies']
        
            cleaned_title= re.sub('[^-a-zA-Z0-9_.()\\\/ ]+', '',  sTitle) #originaltitle)
            try:
                meta = [i for i in meta if cleaned_title.rstrip() in i['file'].rstrip()][0]
            except:
                print("markMovie: Original title not found")
                pass
            xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid" : %s, "playcount" : 1 }, "id": 1 }' % str(meta['movieid']))
        except:
            print("markMovie: Movie not in DB!?")
            pass
示例#15
0
文件: guiTools.py 项目: kiliantv/repo
def markMovie(sTitle):
    if xbmc.getCondVisibility('Library.HasContent(Movies)'):
        try:
            print("Check if movie exists in library when marking as watched")
            meta = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": { "filter": {"field": "playcount", "operator": "is", "value": "0"}, "limits": { "start" : 0, "end": 75 }, "properties" : ["art", "rating", "thumbnail", "playcount", "file"], "sort": { "order": "ascending", "method": "label", "ignorearticle": true } }, "id": "libMovies"}')  
            meta = stringUtils.uni(meta)#(meta, 'utf-8', errors='ignore')
            meta = json.loads(meta)
            meta = meta['result']['movies']
        
            cleaned_title= re.sub('[^-a-zA-Z0-9_.()\\\/ ]+', '',  sTitle) #originaltitle)
            try:
                meta = [i for i in meta if cleaned_title.rstrip() in i['file'].rstrip()][0]
            except:
                print("markMovie: Original title not found")
                pass
            xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.SetMovieDetails", "params": {"movieid" : %s, "playcount" : 1 }, "id": 1 }' % str(meta['movieid']))
        except:
            print("markMovie: Movie not in DB!?")
            pass
示例#16
0
文件: create.py 项目: kiliantv/repo
         except IOError as (errno, strerror):
             print("I/O error({0}): {1}").format(errno, strerror)
         except ValueError:
             print("No valid integer in line.")
         except:
             thisDialog.dialogeBG.close()
             guiTools.infoDialog("Unexpected error: " +
                                 str(sys.exc_info()[1]) +
                                 (". Se your Kodi.log!"))
             utils.addon_log(("Unexpected error: ") +
                             str(sys.exc_info()[1]))
             print("Unexpected error:"), sys.exc_info()[0]
             raise
     pagesDone += 1
     if filetype != 'file' and pagesDone < int(PAGINGalbums):
         contentList = stringUtils.uni(
             jsonUtils.requestList(file, 'video'))
     else:
         pagesDone = int(PAGINGalbums)
     if False:
         try:
             urlUtils.downloadThumb(
                 aThumb, album, os.path.join(STRM_LOC, strm_type,
                                             artist))
         except:
             pass
 else:
     albumList.append([
         os.path.join(strm_type,
                      strm_name.strip().replace('++RenamedTitle++', ''),
                      label.strip()),
         str(utils.multiple_reSub(label.strip(), dictReplacements)),
示例#17
0
文件: create.py 项目: kodinerds/repo
def fillPluginItems(
    url, media_type="video", file_type=False, strm=False, strm_name="", strm_type="Other", showtitle="None"
):
    utils.addon_log("fillPluginItems")

    if not file_type:
        detail = stringUtils.uni(jsonUtils.requestList(url, media_type))
        listLength = len(detail)
    else:
        detail = stringUtils.uni(jsonUtils.requestItem(url, media_type))

    if strm_type.find("Cinema") != -1:
        addMovies(detail, strm_name, strm_type)
        return
    if strm_type.find("TV-Show") != -1:
        addTVShows(detail, strm_name, strm_type)
        return
    if strm_type.find("Shows-Collection") != -1:
        getTVShowFromList(detail, strm_name, strm_type)
        return
    #     if strm_type.find('YouTube') != -1:
    #
    #         video = pafy.new(url)
    #         bestaudio = video.getbestaudio()
    #         bestaudio.bitrate #get bit rate
    #         bestaudio.extension #extension of audio fileurl
    #
    #         bestaudio.url #get url
    #
    #         #download if you want
    #         bestaudio.download()
    #         return

    for f in detail:
        files = re.search('"file" *: *"(.*?)",', f)
        filetypes = re.search('"filetype" *: *"(.*?)",', f)
        labels = re.search('"label" *: *"(.*?)",', f)
        thumbnails = re.search('"thumbnail" *: *"(.*?)",', f)
        fanarts = re.search('"fanart" *: *"(.*?)",', f)
        descriptions = re.search('"description" *: *"(.*?)",', f)

        if filetypes and labels and files:
            filetype = filetypes.group(1)
            label = stringUtils.cleanLabels(labels.group(1))
            file = files.group(1).replace("\\\\", "\\")
            strm_name = str(utils.multiple_reSub(strm_name.rstrip(), dictReplacements))

            if not descriptions:
                description = ""
            else:
                description = stringUtils.cleanLabels(descriptions.group(1))

            thumbnail = thumbnails.group(1)  # stringUtils.removeNonAscii(thumbnails.group(1))
            fanart = fanarts.group(1)  # stringUtils.removeNonAscii(fanarts.group(1))

            if addon.getSetting("Link_Type") == "0":
                link = (
                    sys.argv[0]
                    + "?url="
                    + urllib.quote_plus(file)
                    + "&mode="
                    + str(10)
                    + "&name="
                    + urllib.quote_plus(label)
                    + "&fanart="
                    + urllib.quote_plus(fanart)
                )
            else:
                link = file

            if strm_type.find("TV(") != -1:
                path = os.path.join(strm_type, strm_name)
                filename = str(label)

            if strm_type.find("Movie") != -1:
                path = os.path.join(strm_type, strm_name)
                filename = str(label)

            if strm_type in ["Audio-Album"]:
                path = os.path.join(strm_type, strm_name)
                try:
                    album = re.search('"album" *: *"(.*?)",', f).group(1)
                    try:
                        artist = re.search('"artist" *: *"(.*?)",', f).group(1)
                    except:
                        artist = re.search('"artist"*:*."(.*?)".,', f).group(1)
                    pass
                    titl = re.search('"title" *: *(.*?),', f).group(1)
                    types = re.search('"type" *: *(.*?),', f).group(1)
                    filename = str(strm_name + " - " + label)
                except:
                    filename = str(strm_name + " - " + label)

            if strm_type in ["Audio-Single"]:
                path = os.path.join("Singles", str(strm_name))
                try:
                    album = re.search('"album" *: *"(.*?)",', f).group(1)
                    try:
                        artist = re.search('"artist" *: *"(.*?)",', f).group(1)
                    except:
                        artist = re.search('"artist"*:*."(.*?)".,', f).group(1)
                    pass
                    titl = re.search('"title" *: *(.*?),', f).group(1)
                    types = re.search('"type" *: *(.*?),', f).group(1)
                    filename = str(strm_name + " - " + label)
                except:
                    filename = str(strm_name + " - " + label)

            if strm_type in ["Other"]:
                path = os.path.join("Other", strm_name)
                filename = str(strm_name + " - " + label)

            if filetype == "file":
                if strm:
                    if strm_type == "Audio-Album":
                        utils.addon_log(str(path + " " + filename))
                        utils.createSongNFO(
                            stringUtils.cleanStrms((path.rstrip("."))),
                            stringUtils.cleanStrms(filename.rstrip(".")),
                            strm_ty=strm_type,
                            artists=artist,
                            albums=album,
                            titls=titl,
                            typese=types,
                        )
                    # xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(path + " - " + filename, " writing...",5000,""))
                    fileSys.writeSTRM(
                        stringUtils.cleanStrms((path.rstrip("."))), stringUtils.cleanStrms(filename.rstrip(".")), link
                    )
                else:
                    guiTools.addLink(
                        label, file, 10, thumbnail, fanart, description, "", "", "", None, "", total=len(detail)
                    )
                    # xbmc.executebuiltin("Container.SetViewMode(500)")
            else:
                if strm:
                    fillPluginItems(file, media_type, file_type, strm, label, strm_type)
                else:
                    guiTools.addDir(label, file, 101, thumbnail, fanart, description, "", "", "")
示例#18
0
def getEpisodes(episodesListRaw, strm_name, strm_type, j=0, pagesDone=0):
    episodesList = []
    typeChange = []

    try:
        if type(episodesListRaw) is unicode:
            typeChange.append(episodesListRaw)
            episodesListRaw = typeChange

        for detailInfo in episodesListRaw:
            utils.addon_log("detailInfo: " + detailInfo)
            detailInfo = stringUtils.removeHTMLTAGS(detailInfo)
            files = re.search('"file" *: *"(.*?)",', detailInfo)
            filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
            labels = re.search('"label" *: *"(.*?)",', detailInfo)
            thumbnails = re.search('"thumbnail" *: *"(.*?)",', detailInfo)
            fanarts = re.search('"fanart" *: *"(.*?)",', detailInfo)
            descriptions = re.search('"description" *: *"(.*?)",', detailInfo)
            episodes = re.search('"episode" *: *(.*?),', detailInfo)
            seasons = re.search('"season" *: *(.*?),', detailInfo)
            showtitles = re.search('"showtitle" *: *"(.*?)",', detailInfo)
            provGeneral = re.search(
                '%s(.*)'
                "\\/\\?"
                '' % (r"plugin://plugin.video."), detailInfo)
            provXST = re.search('%s(.*)'
                                "\&function"
                                '' % (r"site="), detailInfo)
            listName = strm_name

            if filetypes:
                if provGeneral:
                    listName = provGeneral.group(1)
                    if provXST:
                        listName = listName + ": " + provXST.group(1)

                if filetypes.group(1) == 'directory':
                    contentList = stringUtils.uni(
                        jsonUtils.requestList(files.group(1), 'video'))
                    continue
                if showtitles and seasons and episodes:
                    filetype = filetypes.group(1)
                    label = (stringUtils.cleanLabels(labels.group(1)))
                    file = (files.group(1).replace("\\\\", "\\"))
                    strm_name = str(
                        stringUtils.cleanByDictReplacements(strm_name.strip()))
                    showtitle = stringUtils.cleanByDictReplacements(
                        (showtitles.group(1)))
                    season = stringUtils.cleanByDictReplacements(
                        seasons.group(1).replace("-", ""))
                    episode = stringUtils.cleanByDictReplacements(
                        episodes.group(1).replace("-", ""))
                    episodesHDF = re.search('Folge.(\\d+)&', file)

                    if file.find("hdfilme") != "-1" and episodesHDF:
                        episode = re.search('Folge.(\\d+)&', file).group(1)

                    if not descriptions:
                        description = ''
                    else:
                        description = stringUtils.cleanLabels(
                            descriptions.group(1))

                    if fanarts:
                        fanart = fanarts.group(1)
                    else:
                        fanart = ''

                    if strm_name.find("++RenamedTitle++") != -1:
                        showtitle = strm_name.strip().replace(
                            '++RenamedTitle++', '')
                    if showtitle != "" and strm_type != "":
                        episodesList.append([
                            strm_type,
                            str('s' + season),
                            str('e' + episode), file,
                            stringUtils.cleanByDictReplacements(
                                showtitle.strip()), listName
                        ])

    except IOError as (errno, strerror):
        print("I/O error({0}): {1}").format(errno, strerror)
示例#19
0
def replacer(*key_values):
    replace_dict = stringUtils.uni(dict(key_values))
    replacement_function = lambda match: replace_dict[match.group(0)]
    pattern = re.compile("|".join([re.escape(k) for k, v in key_values]), re.M)
    return lambda string: pattern.sub(replacement_function, string)
示例#20
0
def fillPluginItems(url, media_type='video', file_type=False, strm=False, strm_name='', strm_type='Other', showtitle='None'):
    initialize_DialogBG("Updating", "Getting content..")
    thisDialog.dialogeBG.update(0, ADDON_NAME + ": Getting: ", stringUtils.getStrmname(strm_name))
    utils.addon_log('fillPluginItems')
    details = []

    if url.find("playMode=play") == -1:
        if not file_type:
            details = jsonUtils.requestList(url, media_type).get('files', [])
        else:
            details = jsonUtils.requestItem(url, media_type).get('files', [])
    else: 
        details.append("palyableSingleMedia")
        details.append(url)

    thisDialog.dialogeBG.close()
    thisDialog.dialogeBG = None  
    if strm_type.find('Cinema') != -1 or strm_type.find('YouTube') != -1 or strm_type.find('Movies') != -1:
        try:
            initialize_DialogBG("Movie", "Adding")
            movieList = addMovies(details, strm_name, strm_type)
            dbMovList = kodiDB.writeMovie(movieList)
            j = 100 / len(dbMovList) if len(dbMovList) > 0 else 1
            # Write strms for all values in movieList
            for entry in dbMovList:
                thisDialog.dialogeBG.update(j, ADDON_NAME + ": Writing Movies: ",  " Video: " + entry.get('title'))
                fileSys.writeSTRM(stringUtils.cleanStrms(entry.get('path')), stringUtils.cleanStrms(entry.get('title')) , "plugin://plugin.video.osmosix/?url=plugin&mode=10&mediaType=movie&id=" + str(entry.get('movieID')) + "|" + entry.get('title'))

                j = j + 100 / len(movieList)
                
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None 
            return      
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1])+ (". See your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print ("Unexpected error:"), sys.exc_info()[0]
            raise
        
    if strm_type.find('TV-Show') != -1 or strm_type.find('Shows-Collection') != -1:
        try:
            initialize_DialogBG("Adding TV-Shows", "working..")
            getTVShowFromList(details, strm_name, strm_type)
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            return
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1])+ (". See your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print ("Unexpected error:"), sys.exc_info()[0]
            raise
        
    if strm_type.find('Album') != -1 :
        try:
            initialize_DialogBG("Album", "Adding")
            addAlbum(details, strm_name, strm_type)
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None       
            return
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1])+ (". See your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print ("Unexpected error:"), sys.exc_info()[0]
            raise

    for detail in details:
        filetype = detail['filetype']
        label = stringUtils.cleanLabels(detail['label'])
        file = detail['file'].replace("\\\\", "\\")
        strm_name = str(stringUtils.cleanByDictReplacements(strm_name.strip()))
        plot = stringUtils.cleanLabels(detail.get('plot',''))
        art = detail.get('art',{})
        
        if addon.getSetting('Link_Type') == '0':
            link = sys.argv[0] + "?url=" +urllib.quote_plus(stringUtils.uni(file)) + "&mode=" + str(10) + "&name=" +urllib.quote_plus(stringUtils.uni(label)) + "&fanart=" + urllib.quote_plus(art.get('fanart',''))
        else:
            link = file
    
        if strm_type == 'Audio-Single':
            path = os.path.join('Singles', str(strm_name))
            try:
                album = detail['album'].strip()
                artist = stringUtils.cleanByDictReplacements(", ".join(artist.strip() for artist in detailInfo['artist']) if isinstance(detailInfo['artist'], (list, tuple)) else detailInfo['artist'].strip())
                title = detail['title'].strip()
                type = detail['type'].strip()
                filename = str(strm_name + ' - ' + label).strip()
            except:
                filename = str(strm_name + ' - ' + label).strip()
                               
        if strm_type.find('Audio-Album') != -1:
            path = os.path.join(strm_type, strm_name)
            track = detail.get('track', 0)
            try:
                album = detail['album'].strip()
                artist = stringUtils.cleanByDictReplacements(", ".join(artist.strip() for artist in detailInfo['artist']) if isinstance(detailInfo['artist'], (list, tuple)) else detailInfo['artist'].strip())
                title = stringUtils.cleanByDictReplacements(detail['title'].strip())
                type = stringUtils.cleanByDictReplacements(detail['type'].strip())
                filename = stringUtils.cleanByDictReplacements(label.strip())
            except:
                filename = stringUtils.cleanByDictReplacements(label.strip())

        if strm_type in ['Other']:
            path = os.path.join('Other', strm_name)
            filename = str(strm_name + ' - ' + label)             
                              
        if filetype == 'file':
            if strm:
                if strm_type.find('Audio-Albums') != -1:
                    kodiDB.musicDatabase(album, artist, label, path, link, track)
                fileSys.writeSTRM(stringUtils.cleanStrms((path.rstrip("."))), stringUtils.cleanStrms(filename.rstrip(".")) , link)
            else:
                guiTools.addLink(label, file, 10, art, plot, '', '', '', None, '', total=len(details))
        else:
            if strm:
                fillPluginItems(file, media_type, file_type, strm, label, strm_type)
            else:
                guiTools.addDir(label, file, 101, art, plot, '', '', '')
示例#21
0
文件: create.py 项目: kodinerds/repo
def addMovies(contentList, strm_name="", strm_type="Other"):
    movieList = []
    pagesDone = 0
    file = ""

    while pagesDone < int(PAGINGMovies):

        for detailInfo in contentList:
            files = re.search('"file" *: *"(.*?)",', detailInfo)
            filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
            labels = re.search('"label" *: *"(.*?)",', detailInfo)
            thumbnails = re.search('"thumbnail" *: *"(.*?)",', detailInfo)
            fanarts = re.search('"fanart" *: *"(.*?)",', detailInfo)
            descriptions = re.search('"description" *: *"(.*?)",', detailInfo)
            try:
                if filetypes and labels and files:
                    filetype = filetypes.group(1)
                    label = stringUtils.cleanLabels(labels.group(1))
                    file = files.group(1).replace("\\\\", "\\")

                    if fanarts:
                        fanart = fanarts.group(1)
                    else:
                        fanart = ""

                    if addon.getSetting("Link_Type") == "0":
                        link = (
                            sys.argv[0]
                            + "?url="
                            + urllib.quote_plus(file)
                            + "&mode="
                            + str(10)
                            + "&name="
                            + urllib.quote_plus(label)
                            + "&fanart="
                            + urllib.quote_plus(fanart)
                        )
                    else:
                        link = file

                    if label and strm_name and label:
                        label = str(utils.multiple_reSub(label.rstrip(), dictReplacements))
                        movieList.append(
                            [
                                os.path.join(strm_type, strm_name, label),
                                str(utils.multiple_reSub(label.rstrip(), dictReplacements)),
                                link,
                            ]
                        )
            except:
                pass

        pagesDone += 1
        if filetype != "file" and pagesDone < int(PAGINGMovies):
            contentList = stringUtils.uni(jsonUtils.requestList(file, "video"))
        else:
            pagesDone = int(PAGINGMovies)
    # Write strms for all values in movieList
    for i in movieList:  # path,name,url(+name)
        fileSys.writeSTRM(
            stringUtils.cleanStrms((i[0].rstrip("."))), stringUtils.cleanStrms(i[1].rstrip(".")), i[2] + "|" + i[1]
        )

    return movieList
示例#22
0
文件: create.py 项目: kiliantv/repo
def getEpisodes(episodesListRaw, strm_name, strm_type, j=0):
    episodesList = []
    typeChange = []

    try:
        if type(episodesListRaw) is unicode:
            typeChange.append(episodesListRaw)
            episodesListRaw = typeChange

        for detailInfo in episodesListRaw:

            detailInfo = stringUtils.removeHTMLTAGS(detailInfo)
            files = re.search('"file" *: *"(.*?)",', detailInfo)
            filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
            labels = re.search('"label" *: *"(.*?)",', detailInfo)
            thumbnails = re.search('"thumbnail" *: *"(.*?)",', detailInfo)
            fanarts = re.search('"fanart" *: *"(.*?)",', detailInfo)
            descriptions = re.search('"description" *: *"(.*?)",', detailInfo)
            episodes = re.search('"episode" *: *(.*?),', detailInfo)
            seasons = re.search('"season" *: *(.*?),', detailInfo)
            showtitles = re.search('"showtitle" *: *"(.*?)",', detailInfo)

            if filetypes:
                if filetypes.group(1) == 'directory':
                    contentList = stringUtils.uni(
                        jsonUtils.requestList(files.group(1), 'video'))
                    continue

                if showtitles and seasons and episodes:
                    filetype = filetypes.group(1)
                    label = (stringUtils.cleanLabels(labels.group(1)))
                    file = (files.group(1).replace("\\\\", "\\"))
                    strm_name = str(
                        utils.multiple_reSub(strm_name.strip(),
                                             dictReplacements))
                    showtitle = utils.multiple_reSub((showtitles.group(1)),
                                                     dictReplacements)
                    season = (utils.multiple_reSub(
                        (seasons.group(1)).replace("-", ""), dictReplacements))
                    episode = (utils.multiple_reSub(
                        (episodes.group(1)).replace("-",
                                                    ""), dictReplacements))
                    episodesHDF = re.search('Folge.(\\d+)&', file)

                    if file.find("hdfilme") != "-1" and episodesHDF:
                        episode = re.search('Folge.(\\d+)&', file).group(1)

                    if not descriptions:
                        description = ''
                    else:
                        description = stringUtils.cleanLabels(
                            descriptions.group(1))

                    if fanarts:
                        fanart = fanarts.group(1)
                    else:
                        fanart = ''

                    if addon.getSetting('Link_Type') == '0':
                        link = sys.argv[0] + "?url=" + urllib.quote_plus(
                            file
                        ) + "&mode=" + str(10) + "&name=" + urllib.quote_plus(
                            label) + "&fanart=" + urllib.quote_plus(fanart)
                    else:
                        link = file


#
                    if strm_name.find("++RenamedTitle++") != -1:
                        showtitle = strm_name.strip().replace(
                            '++RenamedTitle++', '')
                    if showtitle != "" and strm_type != "":
                        episodesList.append([
                            os.path.join(
                                xbmc.translatePath(strm_type + "//" +
                                                   (utils.multiple_reSub(
                                                       showtitle.strip(),
                                                       dictReplacements)))),
                            str('s' + season),
                            str('e' + episode), link
                        ])

    except IOError as (errno, strerror):
        print("I/O error({0}): {1}").format(errno, strerror)
示例#23
0
文件: create.py 项目: kodinerds/repo
def getEpisodes(episodesListRaw, strm_name, strm_type):
    episodesList = []
    typeChange = []
    try:
        if type(episodesListRaw) is unicode:
            typeChange.append(episodesListRaw)
            episodesListRaw = typeChange

        for detailInfo in episodesListRaw:
            files = re.search('"file" *: *"(.*?)",', detailInfo)
            filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo)
            labels = re.search('"label" *: *"(.*?)",', detailInfo)
            thumbnails = re.search('"thumbnail" *: *"(.*?)",', detailInfo)
            fanarts = re.search('"fanart" *: *"(.*?)",', detailInfo)
            descriptions = re.search('"description" *: *"(.*?)",', detailInfo)
            episodes = re.search('"episode" *: *(.*?),', detailInfo)
            seasons = re.search('"season" *: *(.*?),', detailInfo)
            showtitles = re.search('"showtitle" *: *"(.*?)",', detailInfo)

            if filetypes:
                if re.search('"filetype" *: *"(.*?)",', detailInfo).group(1) == "directory":
                    contentList = stringUtils.uni(jsonUtils.requestList(files.group(1), "video"))
                    continue

                if showtitles and seasons and episodes:
                    filetype = filetypes.group(1)
                    label = stringUtils.cleanLabels(labels.group(1))
                    file = files.group(1).replace("\\\\", "\\")
                    strm_name = str(utils.multiple_reSub(strm_name.rstrip(), dictReplacements))
                    showtitle = utils.multiple_reSub((showtitles.group(1)), dictReplacements)
                    season = utils.multiple_reSub((seasons.group(1)).replace("-", ""), dictReplacements)
                    episode = utils.multiple_reSub((episodes.group(1)).replace("-", ""), dictReplacements)

                    if not descriptions:
                        description = ""
                    else:
                        description = stringUtils.cleanLabels(descriptions.group(1))

                    if fanarts:
                        fanart = fanarts.group(1)
                    else:
                        fanart = ""

                    if addon.getSetting("Link_Type") == "0":
                        link = (
                            sys.argv[0]
                            + "?url="
                            + urllib.quote_plus(file)
                            + "&mode="
                            + str(10)
                            + "&name="
                            + urllib.quote_plus(label)
                            + "&fanart="
                            + urllib.quote_plus(fanart)
                        )
                    else:
                        link = file
                    #                     if showtitle.find('10-8:') != -1:
                    #                         x= showtitle
                    episodesList.append(
                        [
                            os.path.join(
                                xbmc.translatePath(
                                    strm_type + "//" + (utils.multiple_reSub(showtitle, dictReplacements))
                                )
                            ),
                            str("s" + season),
                            str("e" + episode),
                            link,
                        ]
                    )
    except IOError as (errno, strerror):
        print "I/O error({0}): {1}".format(errno, strerror)
示例#24
0
文件: utils.py 项目: kodinerds/repo
def replacer(*key_values):
    replace_dict = stringUtils.uni(dict(key_values))
    replacement_function = lambda match: replace_dict[match.group(0)]
    pattern = re.compile("|".join([re.escape(k) for k, v in key_values]), re.M)
    return lambda string: pattern.sub(replacement_function, string)
示例#25
0
文件: create.py 项目: kiliantv/repo
def fillPluginItems(url,
                    media_type='video',
                    file_type=False,
                    strm=False,
                    strm_name='',
                    strm_type='Other',
                    showtitle='None'):
    initialize_DialogBG("Updating", "Getting content..")
    thisDialog.dialogeBG.update(0, ADDON_NAME + ": Getting: ",
                                strm_name.replace('++RenamedTitle++', ''))
    utils.addon_log('fillPluginItems')
    detail = []
    if url.find("playMode=play") == -1:
        if not file_type:
            detail = stringUtils.uni(jsonUtils.requestList(url, media_type))
            listLength = len(detail)
        else:
            detail = stringUtils.uni(jsonUtils.requestItem(url, media_type))
    else:
        detail.append("palyableSingleMedia")
        detail.append(url)

    thisDialog.dialogeBG.close()
    thisDialog.dialogeBG = None
    if strm_type.find('Cinema') != -1 or strm_type.find('YouTube') != -1:
        try:
            initialize_DialogBG("Movie", "Adding")
            addMovies(detail, strm_name, strm_type)
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            return
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) +
                                (". Se your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print("Unexpected error:"), sys.exc_info()[0]
            raise

    if strm_type.find('TVShows sub structures') != -1:
        try:
            initialize_DialogBG("TV-Show SST", "Adding")
            addTVShowsSST(detail, strm_name, strm_type)
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            return
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) +
                                (". Se your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print("Unexpected error:"), sys.exc_info()[0]
            raise

    if strm_type.find('TV-Show') != -1:
        try:
            initialize_DialogBG("TV-Show", "Adding")
            addTVShows(detail, strm_name, strm_type)
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            return
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) +
                                (". Se your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print("Unexpected error:"), sys.exc_info()[0]
            raise

    if strm_type.find('Shows-Collection') != -1:
        try:
            initialize_DialogBG("Shows-Collection", "Adding")
            getTVShowFromList(detail, strm_name, strm_type)
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            return
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) +
                                (". Se your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print("Unexpected error:"), sys.exc_info()[0]
            raise

    if strm_type.find('Album') != -1:
        try:
            initialize_DialogBG("Album", "Adding")
            addAlbum(detail, strm_name, strm_type)
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            return
        except:
            thisDialog.dialogeBG.close()
            thisDialog.dialogeBG = None
            guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) +
                                (". Se your Kodi.log!"))
            utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1]))
            print("Unexpected error:"), sys.exc_info()[0]
            raise


#     if strm_type.find('YouTube') != -1:
#
#         video = pafy.new(url)
#         bestaudio = video.getbestaudio()
#         bestaudio.bitrate #get bit rate
#         bestaudio.extension #extension of audio fileurl
#
#         bestaudio.url #get url
#
#         #download if you want
#         bestaudio.download()
#         return

    for f in detail:
        files = re.search('"file" *: *"(.*?)",', f)
        filetypes = re.search('"filetype" *: *"(.*?)",', f)
        labels = re.search('"label" *: *"(.*?)",', f)
        thumbnails = re.search('"thumbnail" *: *"(.*?)",', f)
        fanarts = re.search('"fanart" *: *"(.*?)",', f)
        descriptions = re.search('"description" *: *"(.*?)",', f)
        tracks = re.search('"track" *: *(.*?),', f)
        durations = re.search('"duration" *: *"(.*?)",', f)

        if filetypes and labels and files:
            filetype = filetypes.group(1)
            label = (stringUtils.cleanLabels(labels.group(1)))
            file = (files.group(1).replace("\\\\", "\\"))
            strm_name = str(
                utils.multiple_reSub(strm_name.strip(), dictReplacements))

            if not descriptions:
                description = ''
            else:
                description = stringUtils.cleanLabels(descriptions.group(1))

            thumbnail = thumbnails.group(
                1)  #stringUtils.removeNonAscii(thumbnails.group(1))
            fanart = fanarts.group(
                1)  #stringUtils.removeNonAscii(fanarts.group(1))

            if addon.getSetting('Link_Type') == '0':
                link = sys.argv[0] + "?url=" + urllib.quote_plus(
                    file) + "&mode=" + str(10) + "&name=" + urllib.quote_plus(
                        label) + "&fanart=" + urllib.quote_plus(fanart)
            else:
                link = file

            if strm_type in ['Audio-Single']:
                path = os.path.join('Singles', str(strm_name))
                try:
                    album = re.search('"album" *: *"(.*?)",',
                                      f).group(1).strip()
                    try:
                        artist = re.search('"artist" *: *"(.*?)",',
                                           f).group(1).strip()
                    except:
                        artist = re.search('"artist"*:*."(.*?)".,',
                                           f).group(1).strip()
                    pass
                    titl = re.search('"title" *: *(.*?),', f).group(1).strip()
                    types = re.search('"type" *: *(.*?),', f).group(1).strip()
                    filename = str(strm_name + ' - ' + label).strip()
                except:
                    filename = str(strm_name + ' - ' + label).strip()

            if strm_type.find('Audio-Album') != -1:
                path = os.path.join(strm_type, strm_name)
                if tracks:
                    track = tracks.group(1)
                try:
                    album = re.search('"album" *: *"(.*?)",',
                                      f).group(1).strip()
                    try:
                        artist = utils.multiple_reSub(
                            re.search('"artist" *: *"(.*?)",',
                                      f).group(1).strip(), dictReplacements)
                    except:
                        artist = utils.multiple_reSub(
                            re.search('"artist"*:*."(.*?)".,',
                                      f).group(1).strip(), dictReplacements)
                    pass
                    titl = utils.multiple_reSub(
                        re.search('"title" *: *(.*?),', f).group(1).strip(),
                        dictReplacements)
                    types = utils.multiple_reSub(
                        re.search('"type" *: *(.*?),', f).group(1).strip(),
                        dictReplacements)
                    filename = utils.multiple_reSub(
                        str(label).strip(), dictReplacements)
                except:
                    filename = utils.multiple_reSub(
                        str(label).strip(), dictReplacements)

            if strm_type in ['Other']:
                path = os.path.join('Other', strm_name)
                filename = str(strm_name + ' - ' + label)

            if filetype == 'file':
                if strm:
                    if strm_type.find('Audio-Albums') != -1:
                        utils.addon_log(str(path + ' ' + filename))
                        #utils.createSongNFO(stringUtils.cleanStrms((path.rstrip("."))), stringUtils.cleanStrms(filename.rstrip(".")), strm_ty=strm_type, artists=artist,albums=album , titls=titl, typese=types)
                        kodiDB.musicDatabase(album, artist, label, path, link,
                                             track)
                    # xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(path + " - " + filename, " writing...",5000,""))
                    fileSys.writeSTRM(
                        stringUtils.cleanStrms((path.rstrip("."))),
                        stringUtils.cleanStrms(filename.rstrip(".")), link)
                else:
                    guiTools.addLink(label,
                                     file,
                                     10,
                                     thumbnail,
                                     fanart,
                                     description,
                                     '',
                                     '',
                                     '',
                                     None,
                                     '',
                                     total=len(detail))
                    # xbmc.executebuiltin("Container.SetViewMode(500)")
            else:
                if strm:
                    fillPluginItems(file, media_type, file_type, strm, label,
                                    strm_type)
                else:
                    guiTools.addDir(label, file, 101, thumbnail, fanart,
                                    description, '', '', '')