コード例 #1
0
def isInMediaList(mediaTitle, url, cType='Other'):
    utils.addon_log('isInMediaList')
    existInList = False

    if not xbmcvfs.exists(profile):
        xbmcvfs.mkdirs(profile)
    if not xbmcvfs.exists(MediaList_LOC):
        xbmcvfs.File(MediaList_LOC, 'a').close()

    thelist = readMediaList()
    if len(thelist) > 0:
        for i in thelist:
            splits = i.strip().split('|')
            if stringUtils.getStrmname(
                    splits[1]) == stringUtils.getStrmname(mediaTitle):
                splitPlugin = re.search('plugin:\/\/([^\/\?]*)', splits[2])
                mediaPlugin = re.search('plugin:\/\/([^\/\?]*)', url)
                if mediaPlugin and splitPlugin and mediaPlugin.group(
                        1) == splitPlugin.group(1):
                    existInList = True

    if existInList:
        return True
    else:
        return False
コード例 #2
0
def writeTutList(step):
    utils.addon_log('writeMediaList')
    existInList = False
    thelist = []
    thefile = xbmc.translatePath(os.path.join(profile, 'firstTimeTut.xml'))
    theentry = '|'.join([step]) + '\n'

    if not xbmcvfs.exists(profile):
        xbmcvfs.mkdirs(profile)
    if not xbmcvfs.exists(thefile):
        open(thefile, 'a').close()

    fle = codecs.open(thefile, "r", 'UTF-8')
    thelist = fle.readlines()
    fle.close()
    del fle

    if len(thelist) > 0:
        for i in thelist:
            if i.find(step) != -1:
                existInList = True
    if existInList != True:
        thelist.append(step)

        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())
            return False
    else:
        return True
コード例 #3
0
def writeTutList(step):
    utils.addon_log('writeTutList')
    existInList = False
    thelist = []
    thefile = os.path.join(profile, 'firstTimeTut.xml')
    theentry = '{0}\n'.format(step)

    if not xbmcvfs.exists(profile):
        xbmcvfs.mkdirs(profile)
    if not xbmcvfs.exists(thefile):
        open(thefile, 'a').close()

    fle = codecs.open(thefile, 'r', 'utf-8')
    thelist = fle.readlines()
    fle.close()
    del fle

    if len(thelist) > 0:
        for i in thelist:
            if i.find(step) != -1:
                existInList = True
    if existInList != True:
        thelist.append(step)

        with open(thefile, 'w') as output_file:
            for linje in thelist:
                if not linje.startswith('\n'):
                    output_file.write('{0}\n'.format(linje.strip()))
                else:
                    output_file.write(linje.strip())
            return False
    else:
        return True
コード例 #4
0
ファイル: guiTools.py プロジェクト: kiliantv/repo
def getSources():
    utils.addon_log('getSources')
    addDir('Video Plugins', 'video', 1, folderIcon, FANART, 'description', 'genre', 'date', 'credits')
    addDir('Music Plugins', 'audio', 1, folderIcon, FANART, 'description', 'genre', 'date', 'credits')
    addDir('UPNP Servers', 'upnp://', 2, folderIcon, FANART, 'description', 'genre', 'date', 'credits')
    addFunction('Update')
    addItem(labels="Remove Media")
コード例 #5
0
ファイル: fileSys.py プロジェクト: kodinerds/repo
def makeSTRM(filepath, filename, url):
    filepath = stringUtils.multiRstrip(filepath.decode("utf-8"))
    filename = filename.decode("utf-8")
    
    utils.addon_log('makeSTRM')
    filepath = os.path.join(STRM_LOC, filepath)
    
    if not xbmcvfs.exists(filepath): 
        xbmcvfs.mkdirs(filepath)
    fullpath = xbmc.translatePath(os.path.join(filepath, filename + '.strm'))

    if xbmcvfs.exists(fullpath):
        if addon.getSetting('Clear_Strms') == 'true':
            x = 0 #xbmcvfs.delete(fullpath)
        else:
            return fullpath
    else:
        try:
            fle = open(fullpath.encode("utf-8"), "w")
        except:
            fle = open(fullpath.decode("utf-8"), "w")
            pass
        fle.write("%s" % url)
        fle.close()
        del fle
        return fullpath
コード例 #6
0
def requestList(path, fletype='video'):
    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)
コード例 #7
0
ファイル: fileSys.py プロジェクト: kodinerds/repo
def writeMediaList(url, name, cType='Other'):
    utils.addon_log('writeMediaList')
    existInList = False
    thelist = []
    thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml'))
    theentry = '|'.join([cType, name.decode("utf-8"), url]) + '\n'  
    
    if not xbmcvfs.exists(profile): 
        xbmcvfs.mkdirs(profile)
    if not xbmcvfs.exists(thefile):
        open(thefile, 'a').close()
    
    fle = codecs.open(thefile, "r", 'UTF-8')
    thelist = fle.readlines()
    fle.close()
    del fle
    
    if len(thelist) > 0:
        for i in thelist:
            if i.split('|',2)[1] == name:
                thelist = stringUtils.replaceStringElem(thelist, theentry, theentry)
                existInList = True     
    if existInList != True:
        thelist.append(theentry)
        
    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())
コード例 #8
0
def getEpisode(episode_item, strm_name, strm_type, j=0, pagesDone=0, name_orig=None):
    episode = None

    utils.addon_log('detailInfo: {0}'.format(episode_item))
    file = episode_item.get('file', None)

    if name_orig and file.find('name_orig=') == -1 and addon.getSetting('Link_Type') == '0':
        file = 'name_orig={0};{1}'.format(name_orig, file)
    episode = episode_item.get('episode', -1)
    split_episode = episode_item.get('split_episode', -1)
    multi_episode = episode_item.get('multi_episode', False)
    season = episode_item.get('season', -1)
    if split_episode > 0:
        strSeasonEpisode = 's{0}e{1}.{2}'.format(season, episode, split_episode)
    else:
        if multi_episode:
            strSeasonEpisode = 's{0}e{1}'.format(season, '-'.join(map(str, episode)))
        else:
            strSeasonEpisode = 's{0}e{1}'.format(season, episode)
    showtitle = episode_item.get('showtitle', None)

    if showtitle is not None and showtitle != '' and strm_type != '':
        path = os.path.join(strm_type, stringUtils.cleanStrmFilesys(showtitle))
        provider = stringUtils.getProviderId(file)
        episode = {'path': path, 'strSeasonEpisode': strSeasonEpisode, 'url': file, 'tvShowTitle': stringUtils.cleanStrmFilesys(showtitle), 'provider': provider.get('providerId')}

        if addon.getSetting('Link_Type') == '0':
            episode = kodiDB.writeShow(episode)

        if episode is not None:
            strm_link = 'plugin://{0}/?url=plugin&mode=10&mediaType=show&episode={1}&showid={2}|{3}'.format(addon_id, episode.get('strSeasonEpisode'), episode.get('showID'), episode.get('tvShowTitle')) if addon.getSetting('Link_Type') == '0' else episode.get('url')
            fileSys.writeSTRM(episode.get('path'), episode.get('strSeasonEpisode'), strm_link)

    return pagesDone
コード例 #9
0
def writeMediaList(url, name, cType='Other', cleanName=True):
    utils.addon_log('writeMediaList')
    existInList = False
    thelist = []
    thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml'))
    theentry = '|'.join([cType, name.decode("utf-8"), url]) + '\n'  
    
    if not xbmcvfs.exists(profile): 
        xbmcvfs.mkdirs(profile)
    if not xbmcvfs.exists(thefile):
        open(thefile, 'a').close()
    
    fle = codecs.open(thefile, "r", 'UTF-8')
    thelist = fle.readlines()
    fle.close()
    del fle
    
    if len(thelist) > 0:
        for i in thelist:
            
            if i.split('|',2)[1] == name:
                xbmcgui.Dialog().notification(str(i), "Adding to MediaList",  os.path.join(ADDON_PATH, 'representerIcon.png'), 5000)
                thelist = stringUtils.replaceStringElem(thelist, theentry, theentry)
                existInList = True     
    if existInList != True:
        thelist.append(theentry)
        
    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())
コード例 #10
0
def requestItem(file, fletype='video'):
    utils.addon_log("requestItem")
    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)
コード例 #11
0
ファイル: fileSys.py プロジェクト: vaginessa/repo
def isInMediaList(mediaTitle, url, cType='Other'):
    utils.addon_log('isInMediaList')
    existInList = False
    thefile = xbmc.translatePath(os.path.join(MEDIALIST_PATH, 'MediaList.xml'))

    if not xbmcvfs.exists(profile):
        xbmcvfs.mkdirs(profile)
    if not xbmcvfs.exists(thefile):
        xbmcvfs.File(thefile, 'a').close()

    fle = xbmcvfs.File(thefile, 'r')
    thelist = fle.read().split('\n')
    fle.close()
    del fle

    if len(thelist) > 0:
        for i in thelist:
            splits = i.strip().split('|')
            if stringUtils.getStrmname(
                    splits[1]) == stringUtils.getStrmname(mediaTitle):
                splitPlugin = re.search('plugin:\/\/([^\/\?]*)', splits[2])
                mediaPlugin = re.search('plugin:\/\/([^\/\?]*)', url)
                if mediaPlugin and splitPlugin and mediaPlugin.group(
                        1) == splitPlugin.group(1):
                    existInList = True

    if existInList:
        return True
    else:
        return False
コード例 #12
0
ファイル: fileSys.py プロジェクト: vaginessa/repo
def makeSTRM(filepath, filename, url):
    utils.addon_log('makeSTRM')

    mtime = None
    try:
        filename = stringUtils.cleanStrmFilesys(filename.decode("utf-8"))
        filepath = stringUtils.multiRstrip(filepath.decode("utf-8"))
        filepath = completePath(os.path.join(STRM_LOC, filepath))

        if not xbmcvfs.exists(filepath):
            dirs = filepath.replace(STRM_LOC, '').split(
                "\\") if filepath.find("\\") != -1 else filepath.replace(
                    STRM_LOC, '').split("/")
            dirs = filter(None, dirs)

            filepath = STRM_LOC
            for dir in dirs:
                filepath = completePath(os.path.join(filepath, dir))
                if not xbmcvfs.exists(filepath):
                    xbmcvfs.mkdir(filepath)

        if not STRM_LOC.startswith("smb:") and not STRM_LOC.startswith('nfs:'):
            fullpath = '%s.strm' % (os.path.normpath(
                xbmc.translatePath(os.path.join(filepath, filename))))
        else:
            fullpath = '%s/%s.strm' % (filepath, filename)


#         if xbmcvfs.exists(fullpath):
#             if addon.getSetting('Clear_Strms') == 'true':
#                 x = 0 #xbmcvfs.delete(fullpath)
#             else:
#                 return fullpath

        if True:
            if fullpath.find('Audio') > 0:
                try:
                    if xbmcvfs.exists(fullpath.decode("utf-8")):
                        return fullpath, None
                except:
                    if xbmcvfs.exists(fullpath.encode("utf-8")):
                        return fullpath, None

            try:
                fullpath = fullpath.decode("utf-8")
                fle = xbmcvfs.File(fullpath, 'w')
            except:
                fullpath = fullpath.encode("utf-8")
                fle = xbmcvfs.File(fullpath, 'w')
                pass

            fle.write(bytearray(url, encoding="utf-8"))
            fle.close()
            del fle

            if fullpath.find('Audio') > 0:
                mtime = os.path.getmtime(fullpath)

    except IOError as (errno, strerror):
        print("I/O error({0}): {1}").format(errno, strerror)
コード例 #13
0
def requestItem(file, fletype='video'):
    utils.addon_log("requestItem, file = " + file)
    if file.find("playMode=play")== -1:
        return requestList(file, fletype)

    json_query = ('{"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":1,"properties":["art","title","year","mpaa","imdbnumber","description","season","episode","playcount","genre","duration","runtime","showtitle","album","artist","plot","plotoutline","tagline","tvshowid"]}, "id": 1}')
    return sendJSON(json_query)
コード例 #14
0
def requestList(path, fletype='video'):
    utils.addon_log("requestList, path = " + path) 
    if path.find("playMode=play")!= -1:
        return requestItem(path, fletype)

    json_query = ('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "properties":["art","title","year","track","mpaa","imdbnumber","description","season","episode","playcount","genre","duration","runtime","showtitle","album","artist","plot","plotoutline","tagline","tvshowid"]}, "id": 1}' % (path, fletype))
    return sendJSON(json_query)
コード例 #15
0
ファイル: guiTools.py プロジェクト: kodinerds/repo
def getSources():
    utils.addon_log('getSources')
    addDir('Video Plugins', 'video', 1, icon, FANART, 'description', 'genre', 'date', 'credits')
    addDir('Music Plugins', 'audio', 1, icon, FANART, 'description', 'genre', 'date', 'credits')
    addDir('UPNP Servers', 'upnp://', 2, icon, FANART, 'description', 'genre', 'date', 'credits')
    addDir('PVR Backend', 'pvr://', 2, icon, FANART, 'description', 'genre', 'date', 'credits')
    addItem(labels="Remove Media")
コード例 #16
0
def getSources():
    utils.addon_log('getSources')
    xbmcplugin.setContent(int(sys.argv[1]), 'files')
    art = {'fanart': FANART, 'thumb': folderIcon}
    addDir('Video Plugins', 'video', 1, art)
    addDir('Music Plugins', 'audio', 1, art)
    addDir('Video Favoriten',
           '',
           102, {'thumb': 'DefaultFavourites.png'},
           type='video')
    addItem('Update', 4, updateIcon)
    addItem('Update (with removal of unused .strm files)', 42, updateIcon)
    addFunction('Update all')
    addItem('Rename', 41, updateIcon)
    addItem('Remove Media', 5, iconRemove)
    addItem('Remove Shows from TVDB cache', 51, iconRemove)
    addItem('Remove all Shows from TVDB cache', 52, iconRemove)
    if xbmc.getCondVisibility('System.HasAddon(service.watchdog)') != 1:
        addon_details = jsonUtils.jsonrpc(
            'Addons.GetAddonDetails',
            dict(addonid='service.watchdog',
                 properties=['enabled', 'installed'])).get('addon')
        if addon_details and addon_details.get('installed'):
            addItem('Activate Watchdog', 7, icon)
        else:
            addItem('Install Watchdog', 6, icon)
コード例 #17
0
ファイル: create.py プロジェクト: kodinerds/repo
def fillPlugins(cType="video"):
    utils.addon_log("fillPlugins, type = " + cType)
    json_query = (
        '{"jsonrpc":"2.0","method":"Addons.GetAddons","params":{"type":"xbmc.addon.%s","properties":["name","path","thumbnail","description","fanart","summary"]}, "id": 1 }'
        % cType
    )
    json_detail = jsonUtils.sendJSON(json_query)
    detail = re.compile("{(.*?)}", re.DOTALL).findall(json_detail)
    for f in detail:
        names = re.search('"name" *: *"(.*?)",', f)
        paths = re.search('"addonid" *: *"(.*?)",', f)
        thumbnails = re.search('"thumbnail" *: *"(.*?)",', f)
        fanarts = re.search('"fanart" *: *"(.*?)",', f)
        descriptions = re.search('"description" *: *"(.*?)",', f)
        if not descriptions:
            descriptions = re.search('"summary" *: *"(.*?)",', f)
        if descriptions:
            description = stringUtils.cleanLabels(descriptions.group(1))
        else:
            description = ""
        if names and paths:
            name = stringUtils.cleanLabels(names.group(1))
            path = paths.group(1)
            if cType == "video" and path.startswith("plugin.video") and not path.startswith("plugin.video.osmosis"):
                thumbnail = thumbnails.group(1)  # stringUtils.removeNonAscii(thumbnails.group(1))
                fanart = fanarts.group(1)  # stringUtils.removeNonAscii(fanarts.group(1))
                guiTools.addDir(name, "plugin://" + path, 101, thumbnail, fanart, description, cType, "date", "credits")
            elif cType == "audio" and path.startswith("plugin.audio") and not path.startswith("plugin.video.osmosis"):
                thumbnail = thumbnails.group(1)  # stringUtils.removeNonAscii(thumbnails.group(1))
                fanart = fanarts.group(1)  # stringUtils.removeNonAscii(fanarts.group(1))
                guiTools.addDir(name, "plugin://" + path, 101, thumbnail, fanart, description, cType, "date", "credits")
コード例 #18
0
def isInMediaList(mediaTitle, url, cType='Other'):
    utils.addon_log('isInMediaList')
    existInList = False
    thelist = []
    thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml'))

    if not xbmcvfs.exists(profile):
        xbmcvfs.mkdirs(profile)
    if not xbmcvfs.exists(thefile):
        open(thefile, 'a').close()

    fle = codecs.open(thefile, "r", 'UTF-8')
    thelist = fle.readlines()
    fle.close()
    del fle

    if len(thelist) > 0:
        for i in thelist:
            splits = i.strip().split('|')
            if splits[1] == mediaTitle:
                splitPlugin = re.search('%s([^\/\?]*)' % ("plugin:\/\/"),
                                        splits[2])
                mediaPlugin = re.search('%s([^\/\?]*)' % ("plugin:\/\/"), url)
                if mediaPlugin and splitPlugin and mediaPlugin.group(
                        1) == splitPlugin.group(1):
                    existInList = True

    if existInList:
        return True
    else:
        return False
コード例 #19
0
def writeSTRM(path, file, url):
    #ToDo: OriginalPlugin option
    #     if addon.getSetting('Link_Type') == '0':
    #         if url.find("plugin://plugin.video.osmosis/?url=plugin") == -1:
    #             url = url.strip().replace("?url=plugin", "plugin://plugin.video.osmosis/?url=plugin", 1)
    utils.addon_log('writeSTRM')
    return makeSTRM(path, file, url)
コード例 #20
0
def addItem(label, mode, icon):
    utils.addon_log('addItem')
    u = "plugin://plugin.video.osmosis/?url=" + "&mode=" + str(mode) + "&fanart=" + urllib.quote_plus(icon)
    liz = xbmcgui.ListItem(label, iconImage=icon, thumbnailImage=icon)
    liz.setInfo(type="Video", infoLabels={ "Title": label,"Genre": "actionRemove"})
    liz.setProperty("Fanart_Image", FANART)

    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=False)     
コード例 #21
0
def addFunction(labels):
    utils.addon_log('addItem')
    u = "plugin://%s/?mode=%s&fanart=%s" % (addon_id, str(666), urllib.quote_plus(updateIcon))
    liz = xbmcgui.ListItem(labels, iconImage=updateIcon, thumbnailImage=updateIcon)
    liz.setInfo(type="Video", infoLabels={ "Title": labels, "Genre": "actionRemove"})
    liz.setProperty("Fanart_Image", FANART)

    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=False)
コード例 #22
0
def addDir(name,
           url,
           mode,
           art,
           plot=None,
           genre=None,
           date=None,
           credits=None,
           showcontext=False,
           name_parent='',
           type=None):
    utils.addon_log('addDir: {0} ({1})'.format(py2_decode(name),
                                               py2_decode(name_parent)))
    u = '{0}?{1}'.format(
        sys.argv[0],
        urllib.urlencode({
            'url': url,
            'name': py2_encode(name),
            'type': type,
            'name_parent': py2_encode(name_parent),
            'fanart': art.get('fanart', '')
        }))
    contextMenu = []
    liz = xbmcgui.ListItem(name)
    liz.setInfo(type='Video',
                infoLabels={
                    'Title': name,
                    'Plot': plot,
                    'Genre': genre,
                    'dateadded': date,
                    'credits': credits
                })
    liz.setArt(art)
    if type == 'tvshow':
        contextMenu.append(('Add TV-Show to MediaList',
                            'XBMC.RunPlugin({0}&mode={1})'.format(u, 200)))
        contextMenu.append(('Add seasons individually to MediaList',
                            'XBMC.RunPlugin({0}&mode={1})'.format(u, 202)))
        xbmcplugin.setContent(int(sys.argv[1]), 'tvshows')
    elif re.findall(
            '( - |, )*([sS](taffel|eason|erie[s]{0,1})|[pP]art|[tT]eil) \d+.*',
            name):
        contextMenu.append(('Add Season to MediaList',
                            'XBMC.RunPlugin({0}&mode={1})'.format(u, 200)))
        xbmcplugin.setContent(int(sys.argv[1]), 'tvshows')
    elif type == 'movie':  # ???
        contextMenu.append(('Add Movie to MediaList',
                            'XBMC.RunPlugin({0}&mode={1})'.format(u, 200)))
        xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    else:
        contextMenu.append(
            ('Create Strms', 'XBMC.RunPlugin({0}&mode={1})'.format(u, 200)))
    liz.addContextMenuItems(contextMenu)

    xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                url='{0}&mode={1}'.format(u, mode),
                                listitem=liz,
                                isFolder=True)
コード例 #23
0
ファイル: fileSys.py プロジェクト: smplgd/repo
def makeSTRM(filepath, filename, url):
    utils.addon_log('makeSTRM')

    isSMB = False
    try:
        filepath = stringUtils.multiRstrip(filepath.decode("utf-8"))
        filename = filename.decode("utf-8")
        filepath = completePath(os.path.join(STRM_LOC, filepath))

        if not xbmcvfs.exists(filepath):
            dirs = filepath.replace(STRM_LOC, '').split(
                "\\") if filepath.find("\\") != -1 else filepath.replace(
                    STRM_LOC, '').split("/")
            dirs = filter(None, dirs)

            filepath = STRM_LOC
            for dir in dirs:
                filepath = completePath(os.path.join(filepath, dir))
                if not xbmcvfs.exists(filepath):
                    xbmcvfs.mkdir(filepath)

        if not STRM_LOC.startswith("smb:"):
            fullpath = os.path.normpath(
                xbmc.translatePath(os.path.join(filepath, filename))) + '.strm'
        else:
            isSMB = True
            fullpath = filepath + "/" + filename + ".strm"


#         if xbmcvfs.exists(fullpath):
#             if addon.getSetting('Clear_Strms') == 'true':
#                 x = 0 #xbmcvfs.delete(fullpath)
#             else:
#                 return fullpath
        if True:
            if isSMB:
                try:
                    fle = xbmcvfs.File(fullpath.decode("utf-8"), 'w')
                except:
                    fle = xbmcvfs.File(fullpath.encode("utf-8"), 'w')
                    pass

                fle.write("%s" % str(url))
                fle.close()
                del fle
            else:
                try:
                    fle = open(fullpath.decode("utf-8"), "w")
                except:
                    fle = open(fullpath.encode("utf-8"), "w")
                    pass

                fle.write("%s" % url)
                fle.close()
                del fle

    except IOError as (errno, strerror):
        print("I/O error({0}): {1}").format(errno, strerror)
コード例 #24
0
def addMultipleSeasonToMediaList(params):
    name = name_orig = params.get('name')
    url = params.get('url')
    selectAction = ['Continue with original Title: {0}'.format(name_orig), 'Rename Title', 'Get Title from Medialist']
    if not fileSys.writeTutList('select:Rename'):
        tutWin = ['Adding content to your library',
                  'You can rename your Movie, TV-Show or Music title.',
                  'To make your scraper recognize the content, some times it is necessary to rename the title.',
                  'Be careful, wrong title can also cause that your scraper can\'t recognize your content.']
        xbmcgui.Dialog().ok(tutWin[0], tutWin[1], tutWin[2], tutWin[3])
    choice = guiTools.selectDialog('Title for MediaList entry: {0}'.format(name_orig), selectAction)
    if choice != -1:
        cType = None
        if name:
            name = stringUtils.cleanLabels(name)

        if choice == 1 or name == None or name == '':
            name = guiTools.editDialog(name).strip()
            name = '{0}++RenamedTitle++'.format(name) if name else name

        if choice == 2:
            item = guiTools.mediaListDialog(False, False, header_prefix='Get Title from Medialist for {0}'.format(name_orig), preselect_name=name, cTypeFilter='TV-Shows')
            splits = item.get('entry').split('|') if item else None
            name = splits[1] if splits else None
            cType = splits[0] if splits else None
        utils.addon_log_notice('addMultipleSeasonToMediaList: name = {0}, cType = {1}'.format(name, cType))
        if name:

            if not cType:
                cType = guiTools.getTypeLangOnly('TV-Shows')

            if cType != -1:
                details = jsonUtils.requestList(url, 'video').get('files', [])
                retry_count = 1
                while len(details) == 0 and retry_count <= 3:
                    utils.addon_log('requestList: try={0} data = {1})'.format(retry_count, details))
                    details = jsonUtils.requestList(url, 'video').get('files', [])
                    retry_count = retry_count + 1
                seasonList = []
                for detail in details:
                    file = detail['file'].replace('\\\\', '\\')
                    filetype = detail['filetype']
                    label = detail['label']
                    if label.find('COLOR') != -1:
                        label = stringUtils.cleanLabels(label) + ' (*)'
                    showtitle = detail['showtitle']
                    name_orig = '{0} - {1}'.format(showtitle, label)
                    if filetype == 'directory':
                        seasonList.append({'label': label, 'name': name, 'name_orig': name_orig, 'url': file, 'cType': cType, 'noninteractive': True})

                sItems = sorted([item.get('label') for item in seasonList], key=lambda k: utils.key_natural_sort(k.lower()))
                preselect = [i for i, item in enumerate(sItems) if item.find(' (*)') == -1]
                selectedItemsIndex = guiTools.selectDialog('Select Seasons to add for {0}'.format(showtitle), sItems, multiselect=True, preselect=preselect)
                seasonList = [item for item in seasonList for index in selectedItemsIndex if item.get('label') == sItems[index]] if selectedItemsIndex and len(selectedItemsIndex) > 0 else None
                utils.addon_log_notice('addMultipleSeasonToMediaList: seasonList = {0}'.format(seasonList))
                if seasonList and len(seasonList) > 0:
                    for season in seasonList:
                        addToMedialist(season)
コード例 #25
0
ファイル: tvdb.py プロジェクト: tjamieg/repository.kodinerds
def getTVShowFromTVDBID(tvdb_id, lang):
    show_data = None
    res = getJsonFromTVDB(api_baseurl.format('series/{0}'.format(tvdb_id)),
                          lang)
    if res.status_code == 200 and len(res.json().get('data')) > 0:
        show_data = res.json().get('data')
    utils.addon_log(
        'tvdb getTVShowFromTVDBID: show_data = {0}'.format(show_data))
    return show_data
コード例 #26
0
ファイル: fileSys.py プロジェクト: kodinerds/repo
def writeSTRM(path, file, url):
    
    utils.addon_log('writeSTRM')
    #ToDo: OriginalPlugin option
    if addon.getSetting('Link_Type') == '0':
        if url.find("plugin://plugin.video.osmosis/?url=plugin") == -1:
            url = url.strip().replace("?url=plugin", "plugin://plugin.video.osmosis/?url=plugin", 1)
   
    makeSTRM(path, file, url)
コード例 #27
0
def removeItemsFromMediaList(action='list'):
    utils.addon_log('removingitemsdialog')

    selectedItems = guiTools.mediaListDialog(header_prefix='Remove item(s) from Medialist', multiselect=True)

    if selectedItems:
        fileSys.removeMediaList(selectedItems)
        selectedLabels = sorted(list(dict.fromkeys([item.get('name') for item in selectedItems])), key=lambda k: k.lower())
        xbmcgui.Dialog().notification('Finished deleting:', '{0}'.format(', '.join(label for label in selectedLabels)))
コード例 #28
0
ファイル: tvdb.py プロジェクト: tjamieg/repository.kodinerds
def getTVShowFromTVDB(showName, lang):
    show_data = None
    params = {'name': showName}
    res = getJsonFromTVDB(api_baseurl.format('search/series'), lang, params)
    if res.status_code == 200 and len(res.json().get('data')) > 0:
        show_data = res.json().get('data')
    utils.addon_log(
        'tvdb getTVShowFromTVDB: show_data = {0}'.format(show_data))
    return show_data
コード例 #29
0
def removeItemsFromMediaList(action='list'):
    utils.addon_log('removingitemsdialog')

    selectedItems = getMediaListDialog()

    if selectedItems is not None:
        fileSys.removeMediaList(selectedItems)
        selectedLabels = [stringUtils.getStrmname(item.split('|')[1]) for item in selectedItems]
        xbmcgui.Dialog().notification("Finished deleting:", "{0}".format(", ".join(label for label in selectedLabels)))
コード例 #30
0
def updateStream(strm_Fullpath, replace_text):
    utils.addon_log('updateStream')
    for line in fileinput.input(strm_Fullpath, inplace=1):
        if not line == replace_text:
            line = line.replace(line, replace_text)
            utils.addon_log('Updated: ' + strm_Fullpath)

    while os.stat(strm_Fullpath).st_size == 0:
        with open(strm_Fullpath, 'w') as newF:
            newF.write(replace_text)
コード例 #31
0
def getSources():
    utils.addon_log('getSources')
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    art = {'fanart': FANART, 'thumb': folderIcon}
    addDir('Video Plugins', 'video', 1, art, 'description', 'genre', 'date', 'credits')
    addDir('Music Plugins', 'audio', 1, art, 'description', 'genre', 'date', 'credits')
    addDir('UPNP Servers', 'upnp://', 2, art, 'description', 'genre', 'date', 'credits')
    addItem('Update', 4, updateIcon)
    addFunction('Update all')
    addItem("Remove Media", 5, iconRemove)
コード例 #32
0
ファイル: fileSys.py プロジェクト: kodinerds/repo
def updateStream(strm_Fullpath, replace_text):
    utils.addon_log('updateStream')
    for line in fileinput.input(strm_Fullpath, inplace=1):
        if not line == replace_text:
            line = line.replace(line, replace_text)
            utils.addon_log('Updated: ' + strm_Fullpath)
            
    while os.stat(strm_Fullpath).st_size == 0:
        with open(strm_Fullpath, 'w') as newF:
            newF.write(replace_text)
コード例 #33
0
def getModule(orig_pluginname):
    extension = None
    if orig_pluginname and orig_pluginname != "":
        pluginname = orig_pluginname.replace('.', '_')
        try:
            extension = __import__('modules.extensions.%s' % pluginname,
                                   fromlist=[pluginname])
        except ImportError:
            utils.addon_log("Extension " + pluginname + " could not be found")

        return extension
コード例 #34
0
ファイル: create.py プロジェクト: kodinerds/repo
def removeItemsFromMediaList(action="list"):
    utils.addon_log("removingitemsdialog")
    thelist = fileSys.readMediaList(purge=False)
    items = [((thelist[i]).strip().split("|")[1]).format(i) for i in range(len(thelist))]
    dialog = dialoge.MultiChoiceDialog("Select items", items)
    dialog.doModal()

    fileSys.removeMediaList(dialog.selected, dictReplacements)

    xbmcgui.Dialog().notification("Finished deleting:", "{0}".format(str(dialog.selectedLabels)))
    del dialog
コード例 #35
0
def getTVShowFromTVDB(token, showName, lang):
    headers = getHeaders({
        'Authorization': 'Bearer %s' % token,
        'Accept-Language': lang
    })
    params = {'name': showName}
    res = requests.get(api_baseurl % 'search/series',
                       headers=headers,
                       params=params)
    utils.addon_log('tvdb searchTVShow: response = %s' % res.json())
    return res
コード例 #36
0
def getSources():
    utils.addon_log('getSources')
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    art = {'fanart': FANART, 'thumb': folderIcon}
    addDir('Video Plugins', 'video', 1, art, 'description', 'genre', 'date', 'credits')
    addDir('Music Plugins', 'audio', 1, art, 'description', 'genre', 'date', 'credits')
    addDir('UPNP Servers', 'upnp://', 2, art, 'description', 'genre', 'date', 'credits')
    addItem('Update', 4, updateIcon)
    addFunction('Update all')
    addItem("Remove Media", 5, iconRemove)
    if xbmc.getCondVisibility('System.HasAddon(service.watchdog)') != 1:
        addItem("Install Watchdog", 6, icon)
コード例 #37
0
ファイル: guiTools.py プロジェクト: kiliantv/repo
def addFunction(labels= 'n.a' ):
    if labels != 'n.a':    
        try:
            utils.addon_log('addItem')
            u = "plugin://plugin.video.osmosis/?url=" + "&mode=" + str(666) + "&fanart=" + urllib.quote_plus(iconRemove)
            ok = True
            liz = xbmcgui.ListItem(labels, iconImage=updateIcon, thumbnailImage=updateIcon)
            liz.setInfo(type="Video", infoLabels={ "Title": labels,"Genre": "actionRemove"})
            liz.setProperty("Fanart_Image", FANART)
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=False)
            #xbmcplugin.endOfDirectory(int(sys.argv[1]), updateListing=True)        
        except:#          
            pass
コード例 #38
0
ファイル: guiTools.py プロジェクト: kodinerds/repo
def addLink(name,url,mode,iconimage,fanart,description,genre,date,showcontext,playlist,regexs,total,setCookie=""): 
    utils.addon_log('addLink') 
    u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&fanart="+urllib.quote_plus(fanart)
    ok = True
    contextMenu =[]
    liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
    liz.setInfo(type="Video", infoLabels={ "Title": name, "Plot": description, "Genre": genre, "dateadded": date })
    liz.setProperty("Fanart_Image", fanart)
    liz.setProperty('IsPlayable', 'true')
    contextMenu.append(('Create Strm','XBMC.RunPlugin(%s&mode=200&name=%s)'%(u, name)))
    liz.addContextMenuItems(contextMenu)
    ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,totalItems=total)
    return ok
コード例 #39
0
ファイル: guiTools.py プロジェクト: kodinerds/repo
def addItem(labels="n.a"):
    if labels != 'n.a':    
        try:
            utils.addon_log('addItem')
            u = "plugin://plugin.video.osmosis/?url=" + "&mode=" + str(5) + "&fanart=" + urllib.quote_plus(iconRemove)
            ok = True
            liz = xbmcgui.ListItem(labels, iconImage="DefaultFolder.png", thumbnailImage="DefaultFolder.png")
            liz.setInfo(type="Video", infoLabels={ "Title": labels,"Genre": "actionRemove"})
            liz.setProperty("Fanart_Image", iconRemove)
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=False)
            xbmcplugin.endOfDirectory(int(sys.argv[1]), updateListing=True)        
        except:#
            
            pass
コード例 #40
0
ファイル: guiTools.py プロジェクト: kodinerds/repo
def addDir(name,url,mode,iconimage,fanart,description,genre,date,credits,showcontext=False):
    utils.addon_log('addDir')
    u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&fanart="+urllib.quote_plus(fanart)
    ok=True
    contextMenu = []
    liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
    liz.setInfo(type="Video", infoLabels={ "Title": name, "Plot": description, "Genre": genre, "dateadded": date, "credits": credits })
    liz.setProperty("Fanart_Image", fanart)
    contextMenu.append(('Create Strms','XBMC.RunPlugin(%s&mode=200&name=%s)'%(u, name)))
    liz.addContextMenuItems(contextMenu)
    try:
        ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
    except:
        pass
    
    return ok
コード例 #41
0
ファイル: fileSys.py プロジェクト: kodinerds/repo
def removeMediaList(Item_remove, replacements):
    utils.addon_log('Removing items')
    thelist = []
    thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml'))
      
    if xbmcvfs.exists(thefile):
        fle = open(thefile, "r")
        thelist = fle.readlines()
        fle.close()
        del fle
        delNotInMediaList(Item_remove, thelist, replacements)
        thelist = [i for j, i in enumerate(thelist) if j not in Item_remove]
        
        fle = open(thefile, "w")
        fle.write(''.join(thelist).strip())
        fle.close()
        del fle
コード例 #42
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, "", "", "")
コード例 #43
0
ファイル: create.py プロジェクト: kodinerds/repo
def getData(url, fanart):
    utils.addon_log("getData, url = " + cType)
コード例 #44
0
ファイル: jsonUtils.py プロジェクト: kodinerds/repo
def requestItem(file, fletype='video'):
    utils.addon_log("requestItem") 
    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)
コード例 #45
0
ファイル: default.py プロジェクト: kodinerds/repo
    except:
        pass
    try:
        playlist = eval(urllib.unquote_plus(params["playlist"]).replace('||', ','))
    except:
        pass
    try:
        fav_mode = int(params["fav_mode"])
    except:
        pass
    try:
        regexs = params["regexs"]
    except:
        pass
    
    utils.addon_log("Mode: " + str(mode))
 
    if not url is None:
        utils.addon_log("URL: " + str(url)) #.encode('utf-8')))
        utils.addon_log("Name: " + str(name))
    #createNFO.setNamePath(STRM_LOC + "\\TV-Shows(de)", 'The Walking Dead', STRM_LOC) 
    if mode == None:
        utils.addon_log("getSources")
        guiTools.getSources()
        try:
            xbmcplugin.endOfDirectory(int(sys.argv[1]))
        except:
            pass
    elif mode == 1:   
        create.fillPlugins(url)
        try:
コード例 #46
0
ファイル: jsonUtils.py プロジェクト: kodinerds/repo
def requestList(path, fletype='video'):
    utils.addon_log("requestList, path = " + path) 
    json_query = ('{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "%s", "media": "%s", "properties":["thumbnail","fanart","title","year","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)
コード例 #47
0
ファイル: fileSys.py プロジェクト: kodinerds/repo
def isMediaList(url, cType='Other'):
    utils.addon_log('isMediaList')