Exemple #1
0
def handlerRoot():
    loginKinopoisk()
    loginRutracker()
    folders = kinopoiskplus.getFolders(_cookiesKinopoisk)
    util.objToFile(folders, _folders)
    for name, id in folders.iteritems():
        params = {'handler': 'ListFolder', 'folder': id}
        item = xbmcgui.ListItem(name, iconImage=_pathImg + 'Folder.png')
        xbmcplugin.addDirectoryItem(handle=_handleId,
                                    url=_baseUrl + '?' +
                                    urllib.urlencode(params),
                                    isFolder=True,
                                    listitem=item)
    rootLinks = [
        {
            'name': 'Поиск',
            'urlParams': {
                'handler': 'Search'
            },
            'icon': _pathImg + 'Search.png'
        }
        #		{'name': 'Рекоммендация', 'urlParams': {'handler': 'Recommendation'}, 'icon': _pathImg+'Recommendation.png'}
    ]
    for rootLink in rootLinks:
        item = xbmcgui.ListItem(rootLink['name'], iconImage=rootLink['icon'])
        xbmcplugin.addDirectoryItem(handle=_handleId,
                                    url=_baseUrl + '?' +
                                    urllib.urlencode(rootLink['urlParams']),
                                    isFolder=True,
                                    listitem=item)
    xbmcplugin.endOfDirectory(_handleId)
Exemple #2
0
def listVideos(content):
    xbmcplugin.setContent(_handleId, 'movies')
    autoplay = []
    autoplayIndex = 0
    for data in content:
        contextMenuItems = []
        contextCmd = 'RunPlugin(' + _baseUrl + '?' + urllib.urlencode(
            {
                'handler': 'AutoPlay',
                'autoplayIndex': str(autoplayIndex)
            }) + ')'
        contextMenuItems.append(('Auto Play', contextCmd))
        infoLabels = {
            "plot":
            '.' + "\n\n\n\n\n" + util.bold('Duration: ') + data['duration'] +
            "\n\n" + util.bold('Date: ') + data['publishedTime'] + "\n\n" +
            util.bold('Views: ') + data['viewCount'] + "\n\n" +
            util.bold('Owner: ') + data['owner'] + "\n\n" +
            util.bold('Privacy: ') + data['privacy']
        }
        name = data["name"]
        item = xbmcgui.ListItem(name)
        item.setArt({
            'thumb': data["thumb"],
            'poster': data["thumb"],
            'fanart': data["thumb"]
        })
        item.setProperty("IsPlayable", "true")
        item.setInfo(type="Video", infoLabels=infoLabels)
        item.addContextMenuItems(contextMenuItems, replaceItems=True)
        live = 'False'
        if data['duration'] == '':
            live = 'True'
        params = {'handler': 'Play', 'id': data['id'], 'name': data['name']}
        autoplay.append(params)
        autoplayIndex = autoplayIndex + 1
        xbmcplugin.addDirectoryItem(handle=_handleId,
                                    url=_baseUrl + '?' +
                                    urllib.urlencode(params),
                                    isFolder=True,
                                    listitem=item)
    util.objToFile(autoplay, _path + '/autoplay')
Exemple #3
0
def handlerListPath():
    autoplay = []
    autoplayIndex = 0
    pathImg = _path + '/resources/img/'
    files = []
    dirs = []
    for f in os.listdir(_params['path']):
        path = os.path.join(_params['path'], f)
        if os.path.isfile(path):
            if util.fileExt(path.lower()) in ['avi', 'mkv', 'mp4']:
                files.append({'name': f, 'path': path})
        else:
            dirs.append({'name': f, 'path': path})
    for f in dirs:
        item = xbmcgui.ListItem(f['name'])
        params = {'handler': 'ListPath', 'path': f['path']}
        xbmcplugin.addDirectoryItem(handle=_handleId,
                                    url=_baseUrl + '?' +
                                    urllib.urlencode(params),
                                    isFolder=True,
                                    listitem=item)
    for f in files:
        contextMenuItems = []
        contextCmd = 'RunPlugin(' + _baseUrl + '?' + urllib.urlencode(
            {
                'handler': 'AutoPlay',
                'autoplayIndex': str(autoplayIndex)
            }) + ')'
        contextMenuItems.append(('Auto Play', contextCmd))
        item = xbmcgui.ListItem(f['name'], iconImage=pathImg + 'video.png')
        item.addContextMenuItems(contextMenuItems, replaceItems=True)
        params = {'handler': 'Play', 'path': f['path'], 'name': f['name']}
        xbmcplugin.addDirectoryItem(handle=_handleId,
                                    url=_baseUrl + '?' +
                                    urllib.urlencode(params),
                                    isFolder=True,
                                    listitem=item)
        autoplay.append(params)
        autoplayIndex = autoplayIndex + 1
    xbmcplugin.endOfDirectory(_handleId)
    util.objToFile(autoplay, _path + '/autoplay')
Exemple #4
0
def handlerListEpisodes():	
	xbmcplugin.setContent(_handleId, 'movies')
	watchlog.init(_watchlogPath,_path + '/watchlog.db')
	if os.path.isfile(_episodesRefreshFlag):
		os.remove(_episodesRefreshFlag)
		episodes = util.fileToObj(_path + '/' + 'content')
	else:
		handler = getattr(__import__(_params['archive']), 'getEpisodes' )	
		episodes = handler(_params['urlProgram'])
		util.objToFile(episodes, _path + '/' + 'content')
	for episode in episodes:
		infoLabels = {}
		contextMenuItems = []
		if watchlog.isWatched(_watchlogPath, _baseUrl, episode['name']):
			infoLabels['playcount'] = 1
			contextCmd = 'RunPlugin(' + _baseUrl+'?' + urllib.urlencode({'handler': 'Watched', 'item': episode['name'], 'watched': 'false'}) + ')'
			contextMenuItems.append(('UnWatched',contextCmd))
		else:
			infoLabels['playcount'] = 0
			contextCmd = 'RunPlugin(' + _baseUrl+'?' + urllib.urlencode({'handler': 'Watched', 'item': episode['name'], 'watched': 'true'}) + ')'
			contextMenuItems.append(('Watched',contextCmd))
		item = xbmcgui.ListItem(episode['name'])	
		item.setArt({'thumb': episode["thumb"], 'poster': episode["thumb"], 'fanart': episode["thumb"]})
		if 'duration' in episode.keys():
			infoLabels['duration'] = float(episode['duration'])
		if 'description' in episode.keys():
			infoLabels['plot'] = episode['description']
		item.setProperty("IsPlayable","true")
		item.setInfo( type="Video", infoLabels=infoLabels )	
		item.addContextMenuItems(contextMenuItems, replaceItems=True)	
		params = {
			'handler': 'PlayEpisode',
			'archive': _params['archive'],
			'url': episode['url'],
			'name': episode['name']
		}
		url = _baseUrl+'?' + urllib.urlencode(params)								
		xbmcplugin.addDirectoryItem(handle=_handleId, url=url, isFolder=True, listitem=item)
		
	xbmcplugin.endOfDirectory(_handleId)
Exemple #5
0
def getOtherAlbums(pathCookies):
    session = initSession(pathCookies)
    loginInfo = google.getLoginInfo(session)
    result = []
    content = session.get("https://photos.google.com/sharing").text
    dummy, i = util.substr("key: 'ds:1'", "return", content)
    data = json.loads(util.parseBrackets(content, i, ['[', ']']))
    util.objToFile(str(data[0][0]),
                   pathCookies.replace('/cookies', '/data.txt'))
    for row in data[0]:
        owner = row[10][0][11][0]
        if owner == loginInfo['name']:
            continue
        result.append({
            'id':
            row[6],
            'sharedKey':
            row[7],
            'name':
            row[1],
            'thumb':
            row[2][0],
            'tsStart':
            None,
            'tsEnd':
            None,
            'photosCount':
            row[3],
            'tsCreated':
            datetime.datetime.fromtimestamp(row[4] / 1000),
            'owner':
            row[10][0][11][0],
            'ownerFlag':
            False
        })

    return result
Exemple #6
0
def setLibrary(library):
    path = _dataFolder + '/library'
    util.objToFile(library, path)
Exemple #7
0
def setDownloads(downloads):
    path = _dataFolder + '/downloads'
    util.objToFile(downloads, path)
Exemple #8
0
def handlerListTorrent():
    xbmcplugin.setContent(_handleId, 'movies')
    autoplay = []
    autoplayIndex = 0
    watchlog.init(_watchedFolder, _path)
    data = transmission.get(_transmissionUrl, _params['hashString'])[0]
    files = sorted(data['files'], key=lambda k: k['name'])
    for file in files:
        if not file['wanted']:
            continue
        contextMenuItems = []
        contextCmd = 'RunPlugin(' + _baseUrl + '?' + urllib.urlencode(
            {
                'handler': 'AutoPlay',
                'autoplayIndex': str(autoplayIndex)
            }) + ')'
        contextMenuItems.append(('Auto Play', contextCmd))
        path = os.path.abspath(_transmissionDownloadsFolder +
                               file['name']).encode('utf8')
        url = 'file://' + urllib.pathname2url(path)
        name = util.fileName(urllib.unquote(url))
        if util.fileExt(path.lower()) not in ['avi', 'mkv', 'mp4']:
            continue
        infoLabels = {}
        if watchlog.isWatched(_watchedFolder, _baseUrl,
                              _params['hashString'] + '|' + name):
            infoLabels['playcount'] = 1
            contextCmd = 'RunPlugin(' + _baseUrl + '?' + urllib.urlencode(
                {
                    'handler': 'Watched',
                    'item': _params['hashString'] + '|' + name,
                    'watched': 'false'
                }) + ')'
            contextMenuItems.append(('UnWatched', contextCmd))
        else:
            infoLabels['playcount'] = 0
            contextCmd = 'RunPlugin(' + _baseUrl + '?' + urllib.urlencode(
                {
                    'handler': 'Watched',
                    'item': _params['hashString'] + '|' + name,
                    'watched': 'true'
                }) + ')'
            contextMenuItems.append(('Watched', contextCmd))
        item = xbmcgui.ListItem(name, iconImage=_pathImg + 'video.png')
        item.addContextMenuItems(contextMenuItems, replaceItems=True)
        item.setInfo(type="Video", infoLabels=infoLabels)
        params = {
            'handler': 'Play',
            'url': url,
            'name': name,
            'hashString': _params['hashString'],
            'item': _params['item']
        }
        url = _baseUrl + '?' + urllib.urlencode(params)
        autoplay.append(params)
        autoplayIndex = autoplayIndex + 1
        xbmcplugin.addDirectoryItem(handle=_handleId,
                                    url=url,
                                    isFolder=True,
                                    listitem=item)
    xbmcplugin.endOfDirectory(_handleId)
    util.objToFile(autoplay, _path + '/autoplay')