Esempio n. 1
0
def logGA(user, channel):
    url = 'http://www.google-analytics.com/collect'
    cid = str(uuid.uuid1())
    cid = cid[cid.rfind('-') + 1:]
    tid = 'UA-63363282-5'
    build = xbmc.getInfoLabel("System.BuildVersion")
    build = 'Kodi ' + build[:build.find(' ')]
    values = {
        'v': '1',
        'tid': tid,
        'cid': cid,
        'uid': user,
        'ds': 'Kodi',
        't': 'pageview',
        'dl': 'c=%s' % (channel),
        'ua': build + '-' + control.addonInfo('name')
    }
    print 'Log', 'c=%s' % (channel)
    data = urllib.urlencode(values)
    req = urllib2.Request(url, data)
    response = urllib2.urlopen(req)
    xbmc.log('logga' + "?????????" * 40)
    return
Esempio n. 2
0
'''

import re
import os
import sys
import urllib
import urllib2
import urlparse
import time
import threading
import control
import cache
import pyxbmct.addonwindow as pyxbmct

downloadPath = control.setting('downloadPath')
property = control.addonInfo('id') + '.downloader'


def downloader():
    thumb = control.addonThumb()
    fanart = control.addonFanart()

    status = control.window.getProperty(property + '.status')

    if not downloadPath == '':
        item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]),
Esempio n. 3
0
def add(items,
        cacheToDisc=True,
        content=None,
        mediatype=None,
        infotype='video'):

    if items is None or len(items) == 0:
        return

    sysicon = control.join(control.addonInfo('path'), 'resources', 'media')
    sysimage = control.addonInfo('icon')
    sysfanart = control.addonInfo('fanart')

    for i in items:
        try:
            try:
                label = control.lang(i['title']).encode('utf-8')
            except:
                label = i['title']

            if 'label' in i and not i['label'] == '0':
                label = i['label']

            if 'image' in i and not i['image'] == '0':
                image = i['image']
            elif 'poster' in i and not i['poster'] == '0':
                image = i['poster']
            elif 'icon' in i and not i['icon'] == '0':
                image = control.join(sysicon, i['icon'])
            else:
                image = sysimage

            if 'banner' in i and not i['banner'] == '0':
                banner = i['banner']
            elif 'fanart' in i and not i['fanart'] == '0':
                banner = i['fanart']
            else:
                banner = image

            fanart = i['fanart'] if 'fanart' in i and not i[
                'fanart'] == '0' else sysfanart

            isFolder = False if 'isFolder' in i and not i[
                'isFolder'] == '0' else True

            url = '%s?action=%s' % (sysaddon, i['action'])

            try:
                url += '&url=%s' % urllib.quote_plus(i['url'])
            except:
                pass
            try:
                url += '&image=%s' % urllib.quote_plus(i['image'])
            except:
                pass

            cm = []
            menus = i['cm'] if 'cm' in i else []

            for menu in menus:
                try:
                    try:
                        tmenu = control.lang(menu['title']).encode('utf-8')
                    except:
                        tmenu = menu['title']
                    qmenu = urllib.urlencode(menu['query'])
                    cm.append((tmenu, 'RunPlugin(%s?%s)' % (sysaddon, qmenu)))
                except:
                    pass

            meta = dict((k, v) for k, v in i.iteritems()
                        if not k == 'cm' and not v == '0')
            if not mediatype == None:
                meta['mediatype'] = mediatype

            item = control.item(label=label,
                                iconImage=image,
                                thumbnailImage=image)

            item.setArt({
                'icon': image,
                'thumb': image,
                'poster': image,
                'tvshow.poster': image,
                'season.poster': image,
                'banner': banner,
                'tvshow.banner': banner,
                'season.banner': banner
            })

            item.setProperty('Fanart_Image', fanart)

            item.addContextMenuItems(cm)
            item.setInfo(type=infotype, infoLabels=meta)
            if isFolder is False:
                item.setProperty(
                    'IsPlayable', 'true'
                ) if not i['action'] == 'pvr_client' else item.setProperty(
                    'IsPlayable', 'false')
                if not i['action'] == 'pvr_client' and infotype == 'video':
                    item.addStreamInfo('video', {'codec': 'h264'})

            control.addItem(handle=syshandle,
                            url=url,
                            listitem=item,
                            isFolder=isFolder)
        except:
            pass

    try:
        i = items[0]
        if i['next'] == '':
            raise Exception()

        url = '%s?action=%s&url=%s' % (sysaddon, i['nextaction'],
                                       urllib.quote_plus(i['next']))
        icon = i['nexticon'] if 'nexticon' in i else control.join(
            sysicon, 'next.png')
        fanart = i['nextfanart'] if 'nextfanart' in i else sysfanart
        try:
            label = control.lang(i['nextlabel']).encode('utf-8')
        except:
            label = 'next'

        item = control.item(label=label, iconImage=icon, thumbnailImage=icon)
        item.setArt({
            'icon': icon,
            'thumb': icon,
            'poster': icon,
            'tvshow.poster': icon,
            'season.poster': icon,
            'banner': icon,
            'tvshow.banner': icon,
            'season.banner': icon
        })
        item.setProperty('Fanart_Image', fanart)
        control.addItem(handle=syshandle,
                        url=url,
                        listitem=item,
                        isFolder=True)
    except:
        pass

    if not content is None:
        control.content(syshandle, content)

    control.directory(syshandle, cacheToDisc=cacheToDisc)
Esempio n. 4
0
import xbmcgui
import xbmcplugin
import control
import imgur
import http_request
from datetime import timedelta

# https://api.imgur.com/endpoints

icon_folder = os.path.join(control.imagesPath, "folder.png")
icon_search = os.path.join(control.imagesPath, "search.png")
icon_next = os.path.join(control.imagesPath, "next-page.png")
icon_settings = os.path.join(control.imagesPath, "settings.png")

subreddits_file = xbmc.translatePath(
    "special://profile/addon_data/%s/subreddits" % control.addonInfo("id"))

image_ext = [".jpg", ".jpeg", ".png", ".bmp", ".webp"]

text_green = "[B][COLOR green][UPPERCASE]%s[/UPPERCASE][/COLOR][/B]"
text_blue = "[B][COLOR blue]%s[/COLOR][/B]"
text_red = "[B][COLOR red]%s[/COLOR][/B]"

text_topic = "[B][COLOR purple]%s[/COLOR][/B]"
text_heading = "[B][COLOR white][UPPERCASE]%s[/UPPERCASE][/COLOR][/B]"


def add_directory(text, icon, thumbnail, url):
    list_item = xbmcgui.ListItem(text,
                                 iconImage=icon,
                                 thumbnailImage=thumbnail)
Esempio n. 5
0
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return. - Muad'Dib
# ----------------------------------------------------------------------------
#######################################################################

# Addon Name: Wraith
# Addon id: script.extendedinfo
# Addon Provider: Mr.Blamo

import os, time, cProfile, StringIO, pstats, json, xbmc

from xbmc import LOGDEBUG, LOGERROR, LOGFATAL, LOGINFO, LOGNONE, LOGNOTICE, LOGSEVERE, LOGWARNING  # @UnusedImport
from datetime import date, datetime, timedelta
import control

name = control.addonInfo('name')
DEBUGPREFIX = '[COLOR purple][ WRAITH DEBUG ][/COLOR]'  # Using color coding, for color formatted log viewers like Assassin's Tools
LOGPATH = xbmc.translatePath('special://logpath/')


def log(msg, level=LOGNOTICE):
    debug_enabled = control.setting('trakt_debug')
    debug_log = control.setting('debug.location')

    print DEBUGPREFIX + ' Debug Enabled?: ' + str(debug_enabled)
    print DEBUGPREFIX + ' Debug Log?: ' + str(debug_log)

    if not control.setting('trakt_debug') == 'true':
        return

    try:
Esempio n. 6
0
import inspect

import control
import traceback
import xbmc

LOGDEBUG = xbmc.LOGDEBUG
LOGERROR = xbmc.LOGERROR
LOGFATAL = xbmc.LOGFATAL
LOGINFO = xbmc.LOGINFO
LOGNONE = xbmc.LOGNONE
LOGNOTICE = xbmc.LOGNOTICE
LOGSEVERE = xbmc.LOGSEVERE
LOGWARNING = xbmc.LOGWARNING

name = control.addonInfo('name')
version = control.addonInfo('version')


def debug(msg, caller=None):
    func = inspect.currentframe().f_back.f_code

    if caller is not None:
        caller = "%s.%s()" % (caller, func.co_name)
    log(msg, caller, level=LOGDEBUG)


def notice(msg, caller=None):
    func = inspect.currentframe().f_back.f_code

    if caller is not None:
Esempio n. 7
0

import re
import os
import sys
import urllib
import urllib2
import urlparse
import time
import threading
import control
import cache
import pyxbmct.addonwindow as pyxbmct

downloadPath = control.setting('downloadPath')
property = control.addonInfo('id') + '.downloader'



def downloader():
    thumb = control.addonThumb() ; fanart = control.addonFanart()

    status = control.window.getProperty(property + '.status')

    if not downloadPath == '':
        item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]), url=downloadPath, listitem=item, isFolder=True)

    if status == 'downloading':
Esempio n. 8
0
def add(items, cacheToDisc=True, content=None, mediatype=None, infotype='video'):

    if items is None or len(items) == 0:
        return

    sysicon = control.join(control.addonInfo('path'), 'resources', 'media')
    sysimage = control.addonInfo('icon')
    sysfanart = control.addonInfo('fanart')

    for i in items:
        try:
            try:
                label = control.lang(i['title']).encode('utf-8')
            except:
                label = i['title']

            if 'label' in i and not i['label'] == '0':
                label = i['label']

            if 'image' in i and not i['image'] == '0':
                image = i['image']
            elif 'poster' in i and not i['poster'] == '0':
                image = i['poster']
            elif 'icon' in i and not i['icon'] == '0':
                image = control.join(sysicon, i['icon'])
            else:
                image = sysimage

            if 'banner' in i and not i['banner'] == '0':
                banner = i['banner']
            elif 'fanart' in i and not i['fanart'] == '0':
                banner = i['fanart']
            else:
                banner = image

            fanart = i['fanart'] if 'fanart' in i and not i['fanart'] == '0' else sysfanart

            isFolder = False if 'isFolder' in i and not i['isFolder'] == '0' else True

            url = '%s?action=%s' % (sysaddon, i['action'])

            try:
                url += '&url=%s' % urllib.quote_plus(i['url'])
            except:
                pass
            try:
                url += '&image=%s' % urllib.quote_plus(i['image'])
            except:
                pass

            cm = []
            menus = i['cm'] if 'cm' in i else []

            for menu in menus:
                try:
                    try:
                        tmenu = control.lang(menu['title']).encode('utf-8')
                    except:
                        tmenu = menu['title']
                    qmenu = urllib.urlencode(menu['query'])
                    cm.append((tmenu, 'RunPlugin(%s?%s)' % (sysaddon, qmenu)))
                except:
                    pass

            meta = dict((k, v) for k, v in i.iteritems() if not k == 'cm' and not v == '0')
            if not mediatype == None:
                meta['mediatype'] = mediatype

            item = control.item(label=label, iconImage=image, thumbnailImage=image)

            item.setArt({'icon': image, 'thumb': image, 'poster': image, 'tvshow.poster': image, 'season.poster': image, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner})

            item.setProperty('Fanart_Image', fanart)

            item.addContextMenuItems(cm)
            item.setInfo(type=infotype, infoLabels = meta)
            if isFolder == False:
                item.setProperty('IsPlayable', 'true') if not i['action'] == 'pvr_client' else item.setProperty('IsPlayable', 'false')

            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder)
        except:
            pass

    try:
        i = items[0]
        if i['next'] == '':
            raise Exception()

        url = '%s?action=%s&url=%s' % (sysaddon, i['nextaction'], urllib.quote_plus(i['next']))
        icon = i['nexticon'] if 'nexticon' in i else control.join(sysicon, 'next.png')
        fanart = i['nextfanart'] if 'nextfanart' in i else sysfanart
        try:
            label = control.lang(i['nextlabel']).encode('utf-8')
        except:
            label = 'next'

        item = control.item(label=label, iconImage=icon, thumbnailImage=icon)
        item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'tvshow.poster': icon, 'season.poster': icon, 'banner': icon, 'tvshow.banner': icon, 'season.banner': icon})
        item.setProperty('Fanart_Image', fanart)
        control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
    except:
        pass

    if not content is None:
        control.content(syshandle, content)

    control.directory(syshandle, cacheToDisc=cacheToDisc)