예제 #1
0
def githubSelect(name):
    from packlib import githubissues

    githubissues.run('tvaddonsco/plugin.video.adultflix', '%s' % name)
    file = xbmc.translatePath(
        os.path.join(kodi.datafolder,
                     '%s-issues-%s.csv' % (kodi.get_id(), name)))

    global msg_text

    with open(file, mode='r') as f:
        txt = f.read()
    items = re.findall('<item>(.+?)</item>', txt, re.DOTALL)
    if len(items) < 1:
        msg_text = kodi.giveColor(
            'No %s issues with AdultFlix at this time.' % name.title(),
            'deeppink', True)
    else:
        msg_text = kodi.giveColor(
            '%s Issues with AdultFlix\n' % name.title(), 'deeppink', True
        ) + kodi.giveColor(
            'Report Issues @ https://github.com/tvaddonsco/plugin.video.adultflix/issues',
            'white', True) + '\n---------------------------------\n\n'
        for item in items:
            try:
                id = re.findall('<id>([^<]+)', item)[0]
            except:
                id = 'Unknown'
            try:
                user = re.findall('<username>([^<]+)', item)[0]
            except:
                user = '******'
            try:
                label = re.findall('<label>([^<]+)', item)[0]
            except:
                label = 'Unknown'
            try:
                title = re.findall('<title>([^<]+)', item)[0]
            except:
                title = 'Unknown'
            try:
                body = re.findall('<body>([^<]+)', item)[0]
            except:
                body = 'Unknown'
            try:
                created = re.findall('<created>([^<]+)', item)[0]
                date, time = created.split('T')
            except:
                date = 'Unknown'
                time = 'Unknwon'
            msg_text += '[B]ID: %s | Label: %s \nBy: %s on %s at %s[/B] \n\nTitle: %s \nMessage %s \n\n---------------------------------\n\n' \
                        % (id,
                           kodi.githubLabel(label),
                           user,
                           date,
                           time.replace('Z', ''),
                           title,
                           body)
예제 #2
0
def run(REPO, STATE):
    """
    Exports Issues from a specified repository to a CSV file
    Uses basic authentication (Github username + password) to retrieve Issues
    from a repository that username has access to. Supports Github API v3.
    """

    ISSUES_FOR_REPO_URL = 'http://api.github.com/repos/%s/issues?state=%s' % (
        REPO, STATE)

    def write_issues(response):
        "output a list of issues to csv"
        if not r.status_code == 200:
            raise Exception(r.status_code)
        for issue in r.json():
            username = issue.get("user", {}).get('login', {})
            if issue['labels']:
                labels = issue['labels']
                for label in labels:
                    # if label['name'] == "Client Requested":
                    csvout.writerow([
                        '\n<item>\n<id>' + str(issue['number']) +
                        '</id>\n<username>' + username +
                        '</username>\n<label>' + label['name'] +
                        '</label>\n<title>' + issue['title'].encode('utf-8') +
                        '</title>\n<body>' + issue['body'].encode('utf-8') +
                        '</body>\n<created>' + issue['created_at'] +
                        '</created>\n</item>\n'
                    ])
            else:
                csvout.writerow([
                    '\n<item>\n<id>' + str(issue['number']) +
                    '</id>\n<username>' + username +
                    '</username>\n<label>No Label</label>\n<title>' +
                    issue['title'].encode('utf-8') + '</title>\n<body>' +
                    issue['body'].encode('utf-8') + '</body>\n<created>' +
                    issue['created_at'] + '</created>\n</item>\n'
                ])

    r = requests.get(ISSUES_FOR_REPO_URL, verify=False)
    csvfile = xbmc.translatePath(
        os.path.join(kodi.datafolder,
                     '%s-issues-%s.csv' % (kodi.get_id(), STATE)))
    csvout = csv.writer(open(csvfile, 'wb'))
    write_issues(r)

    # more pages? examine the 'link' header returned
    if 'link' in r.headers:
        pages = dict([
            (rel[6:-1], url[url.index('<') + 1:-1]) for url, rel in
            [link.split(';') for link in r.headers['link'].split(',')]
        ])
        while 'last' in pages and 'next' in pages:
            r = requests.get(pages['next'])
            write_issues(r)
            if pages['next'] == pages['last']:
                break
예제 #3
0
from __future__ import absolute_import

#############################################################
#################### START ADDON IMPORTS ####################
import os
import re

from packlib import kodi
import pyxbmct.addonwindow as pyxbmct
from kodi_six import xbmc, xbmcaddon
from resources.lib.pyxbmct_.github import xxxtext
from resources.lib.modules import local_utils

#############################################################
#################### SET ADDON ID ###########################
_self_ = xbmcaddon.Addon(id=kodi.get_id())

#############################################################
#################### SET ADDON THEME IMAGES #################
ART = xbmc.translatePath(
    os.path.join('special://home/addons/script.adultflix.artwork',
                 'resources/pyxbmct/issues'))

Background_Image = os.path.join(ART, 'bg.png')
Button = os.path.join(ART, 'close.png')
ButtonF = os.path.join(ART, 'closef.png')
Open = os.path.join(ART, 'numbers/not-selected/open/%s.png')
Open_Selected = os.path.join(ART, 'numbers/selected/open/%s.png')
Closed = os.path.join(ART, 'numbers/not-selected/closed/%s.png')
Closed_Seleted = os.path.join(ART, 'numbers/selected/closed/%s.png')
예제 #4
0
    def get_list(self,
                 mode,
                 type,
                 url,
                 title_pattern,
                 url_pattern,
                 icon_pattern=None,
                 site=None,
                 d_p1=None,
                 d_p2=None,
                 d_p3=None,
                 parse=None,
                 cache_time=None,
                 searched=False,
                 stopend=False,
                 isVideo=False,
                 isDownloadable=False):

        if cache_time:
            r = cache.get(client.request, cache_time, url)
        else:
            r = client.request(url)

        if 're|' in d_p3:
            d_p3 = d_p3.replace('re|', '')
            r = dom_parser2.parse_dom(r, d_p1, {d_p2: re.compile('%s' % d_p3)})
        else:
            r = dom_parser2.parse_dom(r, d_p1, {d_p2: d_p3})

        if r:

            dirlst = []

            for i in r:
                name = re.findall(r'%s' % title_pattern, i.content)[0]
                name = kodi.sortX(i[1].encode('utf-8'))
                url = re.findall(r'%s' % url_pattern, i.content)[0]
                if icon_pattern:
                    iconimage = re.findall(r'%s' % icon_pattern, i.content)[0]
                elif site:
                    iconimage = xbmc.translatePath(
                        os.path.join(
                            'special://home/addons/script.adultflix.artwork',
                            'resources/art/%s/icon.png' % site))
                else:
                    iconimage = xbmc.translatePath(
                        os.path.join('special://home/addons/' + kodi.get_id(),
                                     'icon.png'))
                fanarts = xbmc.translatePath(
                    os.path.join(
                        'special://home/addons/script.adultflix.artwork',
                        'resources/art/%s/fanart.jpg' % site))
                if parse:
                    link, tag = parse.split('|SPLIT|')
                    if tag == 'url':
                        url = urljoin(link, url)
                    elif tag == 'icon':
                        iconimage = urljoin(link, iconimage)
                    else:
                        url = urljoin(link, url)
                        iconimage = urljoin(link, iconimage)
                if site: url += '|SPLIT|' + site
                if type == 'dir':
                    dirlst.append({
                        'name': kodi.giveColor(name, 'white'),
                        'url': url,
                        'mode': mode,
                        'icon': iconimage,
                        'fanart': fanarts,
                        'description': name,
                        'folder': True
                    })
                else:
                    dirlst.append({
                        'name': kodi.giveColor(name, 'white'),
                        'url': url,
                        'mode': mode,
                        'icon': iconimage,
                        'fanart': fanarts,
                        'description': name,
                        'folder': False
                    })

            if dirlst:
                if stopend:
                    buildDirectory(dirlst,
                                   stopend=True,
                                   isVideo=isVideo,
                                   isDownloadable=isDownloadable)
                else:
                    buildDirectory(dirlst,
                                   isVideo=isVideo,
                                   isDownloadable=isDownloadable)