예제 #1
0
 def test_add_directory_items(self):
     list_item1 = mock.MagicMock()
     context1 = ListContext(
         [{
             'url': 'plugin://foo',
             'list_item': list_item1,
             'is_folder': True
         }],
         True,
         True,
         True,
         (0,),
         50,
         'movies'
     )
     plugin = Plugin('test.plugin')
     plugin._handle = 1
     plugin.create_list_item = mock.MagicMock()
     plugin._add_directory_items(context1)
     mock_xbmcplugin.setContent.assert_called_with(1, 'movies')
     mock_xbmcplugin.addDirectoryItem.assert_called_with(1, 'plugin://foo', list_item1, True)
     mock_xbmcplugin.addSortMethod.assert_called_with(1, 0)
     mock_xbmcplugin.endOfDirectory.assert_called_with(1, True, True, True)
     mock_xbmc.executebuiltin.assert_called_with('Container.SetViewMode(50)')
     mock_xbmcplugin.addDirectoryItems.reset_mock()
     context2 = ListContext(
         [{
             'url' : 'plugin://foo',
             'label': 'Foo',
             'is_folder': True
         }],
         True,
         True,
         True,
         (0,),
         50,
         'movies'
     )
     list_item2 = mock.MagicMock()
     plugin.create_list_item.return_value = list_item2
     plugin._add_directory_items(context2)
     mock_xbmcplugin.addDirectoryItem.assert_called_with(1, 'plugin://foo', list_item2, True)
     mock_xbmcplugin.addDirectoryItems.reset_mock()
     list_item2.reset_mock()
     context3 = ListContext(
         [{
             'url' : 'plugin://foo',
             'label': 'Foo',
             'is_playable': True
         }],
         True,
         True,
         True,
         (0,),
         50,
         'movies'
     )
     plugin._add_directory_items(context3)
     list_item2.setProperty.assert_called_with('IsPlayable', 'true')
     mock_xbmcplugin.addDirectoryItem.assert_called_with(1, 'plugin://foo', list_item2, False)
예제 #2
0
def play(params):
    """Play video"""
    path = ott_stream%(KEY, params.url)
    extra = ''
    
    if params.timeshift!= None and __addon__.getSetting('askts') != 'false':
         i = xbmcgui.Dialog().select('Use timeshift', ['Yes', 'No'])
         if i:
             params.archive = params.timeshift
             params.timeshift = None

    if params.archive!= None:
        extra += '?archive=%s'%params.archive
        if params.archive_end!= None:  extra += '&archive_end=%s'%params.archive_end

    if params.timeshift!= None and params.timenow != None:
        if extra != "": extra += '&'
        else: extra = '?'
        extra += 'timeshift=%s&timenow=%s'%(params.timeshift, params.timenow)
        
    if params.archive!= None: page = 'arch/' + params.url
    else: page = 'live/' + params.url
    track(QT(page), params.rand)

    return Plugin.resolve_url(path + extra, succeeded=True)
예제 #3
0
def by_genre(params):
    xbmcplugin.setContent(int(sys.argv[1]), 'files')

    #vsdbg._bp()

    listing = [
        genre_item(genre) for genre in shikicore.genres()
        if genre['kind'] == 'anime'
    ]
    return Plugin.create_listing(
        listing,
        sort_methods=(xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE,
                      xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE))
예제 #4
0
 def test_create_list_item(self):
     item = {
         'label': 'Label',
         'label2': 'Label2',
         'path': '/path/foo',
         'thumb': 'thumb.png',
         'icon': 'icon.png',
         'fanart': 'fanart.jpg',
         'art': {'poster': 'poster.jpg', 'banner': 'banner.jpg'},
         'stream_info': {'video': {'codec': 'h264'}},
         'info': {'video': {'genre': 'Comedy'}},
         'context_menu': ['item1', 'item2'],
         'subtitles': 'subs.srt',
         'mime': 'video/x-matroska',
     }
     mock_xbmc.getInfoLabel.return_value = '15.0'
     Plugin.create_list_item(item)
     mock_xbmcgui.ListItem.assert_called_with(label='Label', label2='Label2', path='/path/foo')
     mock_ListItem.setThumbnailImage.assert_called_with('thumb.png')
     mock_ListItem.setIconImage.assert_called_with('icon.png')
     mock_ListItem.setProperty.assert_called_with('fanart_image', 'fanart.jpg')
     mock_ListItem.setArt.assert_called_with(item['art'])
     mock_ListItem.addStreamInfo.assert_called_with('video', {'codec': 'h264'})
     mock_ListItem.setInfo('video', {'genre': 'Comedy'})
     mock_ListItem.addContextMenuItems.assert_called_with(['item1', 'item2'])
     mock_ListItem.setSubtitles.assert_called_with('subs.srt')
     mock_ListItem.setMimeType.assert_called_with('video/x-matroska')
     # Test for Kodi Jarvis API
     mock_xbmc.getInfoLabel.return_value = '16.0'
     mock_ListItem.setArt.reset_mock()
     Plugin.create_list_item(item)
     mock_ListItem.setArt.assert_called_with({'icon': 'icon.png',
                                              'thumb': 'thumb.png',
                                              'fanart': 'fanart.jpg',
                                              'poster': 'poster.jpg',
                                              'banner': 'banner.jpg'})
예제 #5
0
 def test_set_resolved_url(self):
     context1 = PlayContext('http://foo.bar', None, True)
     plugin = Plugin('test.plugin')
     plugin._handle = 1
     mock_xbmcgui.ListItem.reset_mock()
     plugin._set_resolved_url(context1)
     mock_xbmcgui.ListItem.assert_called_with(path='http://foo.bar')
     mock_xbmcplugin.setResolvedUrl.assert_called_with(
         1, True, mock_ListItem)
     mock_xbmcplugin.setResolvedUrl.reset_mock()
     play_item = mock.MagicMock()
     context2 = PlayContext('http://foo.bar', play_item, True)
     list_item = mock.MagicMock()
     plugin.create_list_item = mock.MagicMock()
     plugin.create_list_item.return_value = list_item
     plugin._set_resolved_url(context2)
     plugin.create_list_item.assert_called_with(play_item)
     mock_xbmcplugin.setResolvedUrl.assert_called_with(1, True, list_item)
예제 #6
0
 def test_run(self):
     plugin = Plugin('test.plugin')
     mock_actions = mock.MagicMock()
     mock_actions.root.return_value = None
     mock_actions.foo.return_value = None
     plugin.actions['root'] = mock_actions.root
     plugin.actions['foo'] = mock_actions.foo
     # Test calling 'root' action
     with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '']):
         plugin.run()
         mock_actions.root.assert_called_with({})
     # Test calling an action with parameters
     with mock.patch('simpleplugin.sys.argv',
                     ['test.plugin', '1', '?action=foo&param=bar']):
         plugin.run()
         mock_actions.foo.assert_called_with({
             'action': 'foo',
             'param': 'bar'
         })
예제 #7
0
 def test_set_resolved_url(self):
     context1 = PlayContext('http://foo.bar', None, True)
     plugin = Plugin('test.plugin')
     plugin._handle = 1
     mock_xbmcgui.ListItem.reset_mock()
     plugin._set_resolved_url(context1)
     mock_xbmcgui.ListItem.assert_called_with(path='http://foo.bar')
     mock_xbmcplugin.setResolvedUrl.assert_called_with(1, True, mock_ListItem)
     mock_xbmcplugin.setResolvedUrl.reset_mock()
     play_item = mock.MagicMock()
     context2 = PlayContext('http://foo.bar', play_item, True)
     list_item = mock.MagicMock()
     plugin.create_list_item = mock.MagicMock()
     plugin.create_list_item.return_value = list_item
     plugin._set_resolved_url(context2)
     plugin.create_list_item.assert_called_with(play_item)
     mock_xbmcplugin.setResolvedUrl.assert_called_with(1, True, list_item)
예제 #8
0
    def test_action_decorator(self):
        plugin = Plugin('test.plugin')

        @plugin.action()
        def foo(params):
            raise AssertionError('Test passed!')

        try:

            @plugin.action('foo')
            def bar(params):
                pass
        except SimplePluginError:
            pass
        else:
            self.fail('Duplicate action names test failed!')

        with mock.patch('simpleplugin.sys.argv',
                        ['test.plugin', '1', '?action=foo']):
            self.assertRaises(AssertionError, plugin.run)
예제 #9
0
    def test_run(self):
        plugin = Plugin('test.plugin')
        plugin.create_listing = mock.MagicMock()
        plugin.resolve_url = mock.MagicMock()
        plugin._add_directory_items = mock.MagicMock()
        plugin._set_resolved_url = mock.MagicMock()
        mock_actions = mock.MagicMock()
        # Test calling 'root' action
        with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '']):
            mock_actions.root.return_value = [{'label': 'root'}]
            plugin.actions['root'] = mock_actions.root
            plugin.run(category='Foo')
            mock_actions.root.assert_called_with({})
            plugin.create_listing.assert_called_with([{'label': 'root'}])
            # Test setting plugin category
            mock_xbmcplugin.setPluginCategory.assert_called_with(1, 'Foo')
        # Test calling a child action returning list or generator
        with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '?action=foo&param=bar']):
            plugin.create_listing.reset_mock()
            mock_actions.foo.return_value = [{'label': 'foo'}]
            plugin.actions['foo'] = mock_actions.foo
            plugin.run()
            mock_actions.foo.assert_called_with({'action': 'foo', 'param': 'bar'})
            plugin.create_listing.assert_called_with([{'label': 'foo'}])
            plugin.create_listing.reset_mock()
            generator = test_generator()
            mock_actions.foo.return_value = generator
            plugin.run()
            mock_actions.foo.assert_called_with({'action': 'foo', 'param': 'bar'})
            plugin.create_listing.assert_called_with(generator)
        # Test calling a child action returning a str
        with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '?action=play_str']):
            mock_actions.play_str.return_value = '/play/path'
            plugin.actions['play_str'] = mock_actions.play_str
            plugin.run()
            plugin.resolve_url.assert_called_with('/play/path')
        # Test calling a child action returning ListContext namedtuple
        with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '?action=tuple_listing']):
            plugin._add_directory_items.reset_mock()
            list_context = ListContext(
                [{
                    'url': 'plugin://foo',
                    'label': 'Foo',
                    'is_folder': True
                }],
                True,
                True,
                True,
                (0,),
                50,
                'movies'
            )

            mock_actions.dict_listing.return_value = list_context
            plugin.actions['tuple_listing'] = mock_actions.dict_listing
            plugin.run()
            plugin._add_directory_items.assert_called_with(list_context)
        # Test calling a child action returning PlayContext namedtuple
        with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '?action=tuple_play']):
            plugin._set_resolved_url.reset_mock()
            play_context = PlayContext('http://foo.bar', None, True)
            mock_actions.dict_play.return_value = play_context
            plugin.actions['tuple_play'] = mock_actions.dict_play
            plugin.run()
            plugin._set_resolved_url.assert_called_with(play_context)
        # Test unregistered action
        with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '?action=invalid']):
            self.assertRaises(SimplePluginError, plugin.run)
예제 #10
0
 def test_get_params(self, *args):
     params = Plugin.get_params('param1=value1&param1=value2&param3=value3')
     self.assertEqual(params['param1'], ['value1', 'value2'])
     self.assertEqual(params['param3'], 'value3')
예제 #11
0
# This plugin uses my SimplePlugin library:
# https://github.com/romanvm/script.module.simpleplugin

import os
import urllib
import re
from collections import namedtuple
import xbmc
import xbmcgui
from simpleplugin import Plugin
import exua
import webclient
import login_window

plugin = Plugin()
icons = os.path.join(plugin.path, 'resources', 'icons')
commands = os.path.join(plugin.path, 'libs', 'commands.py')
_ = plugin.initialize_gettext()

SearchQuery = namedtuple('SearchQuery', ['query', 'path'])
dialog = xbmcgui.Dialog()


def _media_categories(categories, content):
    """
    Create media categories listing
    """
    for category in categories:
        yield {
            'label': u'{0} [COLOR=gray][{1}][/COLOR]'.format(category.name, category.items),
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html

import xbmc
import xbmcgui
import xbmcaddon
import xbmcplugin
import urllib
import json
import pyxbmct
import threading

import gui

from simpleplugin import Plugin

plugin = Plugin('plugin.video.united.search')
_ = plugin.initialize_gettext()

def _get_directory_threaded( us, directory ):
    us.result = []
    for item in us.get_directory(directory):
        us.result.append(item)

class UnitedSearch(object):
    def __init__( self ):
        self.__load_supported_addons()

    def search( self, params ):
        succeeded = False
        only_search = (params.get('only_search', 'False') == 'True')
예제 #13
0
# -*- coding: utf-8 -*-
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html

import xbmc
import xbmcaddon
import pyxbmct

from simpleplugin import Plugin

plugin = Plugin()
_ = plugin.initialize_gettext()


class SupportedAddonsSettings(pyxbmct.AddonDialogWindow):
    def __init__(self, supported_addons):
        super(SupportedAddonsSettings, self).__init__(_('Supported Add-ons'))
        self._supported_addons = supported_addons

        self.setGeometry(700, 450, 9, 4)

        self.page = 0
        self.list = []
        self.set_active_controls()
        self.set_navigation()

        self.draw_page()

        # Connect a key action (Backspace) to close the window.
        self.connect(pyxbmct.ACTION_NAV_BACK, self.close)

    def set_active_controls(self):
예제 #14
0
        if resp != None:
            dbg_log("--gotit")
            cf = open(fn, 'w')
            cf.write(str(tt) + '\n')
            cf.write(type + '\n')
            cf.write(resp + '\n')
            cf.close()
            cache = resp
    return cache


from simpleplugin import Plugin
import time, calendar


plugin = Plugin()

@plugin.action()
def root():

    rand = str(random.random())
        
    return [{'label': 'LiveTV',
            'url': plugin.get_url(action='live', rand=rand)},
            {'label': 'Archive',
            'url': plugin.get_url(action='arch', rand=rand)},
            {'label': 'Settings',
            'url': plugin.get_url(action='settings', rand=rand)}]


@plugin.action()
예제 #15
0
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
"""Add extended info to torrents"""

import sys
import os
import re
from collections import namedtuple
from traceback import format_exc
from simpleplugin import Plugin
import tvdb
import rarbg
from rarbg_exceptions import RarbgError

__all__ = ['get_torrents', 'OrderedDict', 'check_proper']

plugin = Plugin('plugin.video.rk.tv')
sys.path.append(os.path.join(plugin.path, 'site-packages'))
import concurrent.futures as futures
try:
    from collections import OrderedDict
except ImportError:
    from ordereddict import OrderedDict

episode_regexes = (re.compile(r'^.+?\.s(\d+)e(\d+)\.',
                              re.I), re.compile(r'^.+?\.(\d+)x(\d+)\.', re.I))
proper_regex = re.compile(r'^.+?\.(s\d+e\d+|\d+x\d+)\..*?(proper|repack).*?$',
                          re.I)
EpData = namedtuple('EpData', ['season', 'episode'])


def check_proper(name):
예제 #16
0
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
"""Add extended info to torrents"""

import sys
import os
import re
from collections import namedtuple
from traceback import format_exc
from simpleplugin import Plugin
import tvdb
import rarbg
from rarbg_exceptions import RarbgError

__all__ = ['get_torrents', 'OrderedDict', 'check_proper']

plugin = Plugin('plugin.video.rarbg.tv')
sys.path.append(os.path.join(plugin.path, 'site-packages'))
import concurrent.futures as futures
try:
    from collections import OrderedDict
except ImportError:
    from ordereddict import OrderedDict

episode_regexes = (re.compile(r'^.+?\.s(\d+)e(\d+)\.',
                              re.I), re.compile(r'^.+?\.(\d+)x(\d+)\.', re.I))
proper_regex = re.compile(r'^.+?\.(s\d+e\d+|\d+x\d+)\..*?(proper|repack).*?$',
                          re.I)
EpData = namedtuple('EpData', ['season', 'episode'])


def check_proper(name):
예제 #17
0
파일: default.py 프로젝트: vkravets/ru
# -*- coding: utf-8 -*-
# Module: default
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html

import xbmc
import xbmcgui
import xbmcaddon
import urllib
import simplejson as json

from simpleplugin import Plugin

plugin = Plugin()
_ = plugin.initialize_gettext()

_supported_addons = []

def get_categories():
    categories = [ {'action': 'search',           'label': _('New Search'), 'is_folder': False},
                   {'action': 'search_results',   'label': _('Last Search')},
                   {'action': 'search_history',   'label': _('Search History')},
                   {'action': 'supported_addons', 'label': _('Supported Add-ons')} ]

    return categories

def show_info_notification(text):
    xbmcgui.Dialog().notification(plugin.addon.getAddonInfo('name'), text)

def make_items( video_list, addon_name ):
    listing = []
예제 #18
0
 def test_get_url(self, *args):
     plugin = Plugin('test.plugin')
     self.assertEqual(plugin.get_url(), 'plugin://test.plugin/')
     self.assertEqual(plugin.get_url(action='test'), 'plugin://test.plugin/?action=test')
     self.assertEqual(plugin.get_url('plugin://other.plugin/', param='value'), 'plugin://other.plugin/?param=value')
# -*- coding: utf-8 -*-
# Module: main
# Author: Roman V. M.
# Created on: 28.11.2014
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html

from simpleplugin import Plugin

# Create plugin instance
plugin = Plugin()

# Free sample videos are provided by www.vidsplay.com
# Here we use a fixed set of properties simply for demonstrating purposes
# In a "real life" plugin you will need to get info and links to video files/streams
# from some web-site or online service.
VIDEOS = {'Animals': [{'name': 'Crab',
                       'thumb': 'http://www.vidsplay.com/vids/crab.jpg',
                       'video': 'http://www.vidsplay.com/vids/crab.mp4'},
                      {'name': 'Alligator',
                       'thumb': 'http://www.vidsplay.com/vids/alligator.jpg',
                       'video': 'http://www.vidsplay.com/vids/alligator.mp4'},
                      {'name': 'Turtle',
                       'thumb': 'http://www.vidsplay.com/vids/turtle.jpg',
                       'video': 'http://www.vidsplay.com/vids/turtle.mp4'}
                      ],
            'Cars': [{'name': 'Postal Truck',
                      'thumb': 'http://www.vidsplay.com/vids/us_postal.jpg',
                      'video': 'http://www.vidsplay.com/vids/us_postal.mp4'},
                     {'name': 'Traffic',
                      'thumb': 'http://www.vidsplay.com/vids/traffic1.jpg',
                      'video': 'http://www.vidsplay.com/vids/traffic1.avi'},
예제 #20
0
 def test_get_params(self, *args):
     params = Plugin.get_params('param1=value1&param1=value2&param3=value3')
     self.assertEqual(params['param1'], ['value1', 'value2'])
     self.assertEqual(params['param3'], 'value3')
예제 #21
0
# -*- coding: utf-8 -*-
# Author: Roman V.M.
# Created on: 17.06.2015
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
"""Get info from TheTVDB"""

from simpleplugin import Plugin
from web_client import load_page
from rarbg_exceptions import TvdbError

plugin = Plugin('plugin.video.rk.tv')

import xml.etree.cElementTree as etree
try:
    etree.fromstring('<?xml version="1.0"?><foo><bar/></foo>')
except TypeError:
    plugin.log_warning('cElementTree is not available! Falling back to ElementTree.')
    import xml.etree.ElementTree as etree

__all__ = ['get_series', 'get_episode', 'search_series']

APIKEY = '41277F23AA12DE38'
GET_SERIES = 'http://thetvdb.com/api/{apikey}/series/{id}/en.xml'
GET_EPISODE = 'http://thetvdb.com/api/{apikey}/series/{id}/default/{season}/{episode}/en.xml'
SEARCH_SERIES = 'http://thetvdb.com/api/GetSeries.php'
GET_BY_ID = 'http://thetvdb.com/api/GetSeriesByRemoteID.php'
GRAPHICS = 'http://thetvdb.com/banners/'


def parse_items(parent):
    """
예제 #22
0
# -*- coding: utf-8 -*-
# Module: plugin.video.xnxx
# Author: moedje (Roman V. M. SimplePlugin/example framework)
# Created on: 27.08.2017
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
import sys, json, os, re, simpleutils
import xbmc, xbmcgui
from urllib import quote_plus
from simpleplugin import Plugin, Params
from operator import itemgetter

plugin = Plugin()   # Get the plugin url in plugin:// notation.
_url = sys.argv[0]  # Get the plugin handle as an integer number.
_handle = int(sys.argv[1])
__addondir__ = xbmc.translatePath(plugin.addon.getAddonInfo('path'))
__resources__ = os.path.join(__addondir__, 'resources/')
__next__ = os.path.join(__resources__, "next.png")
__filtersex__ = plugin.get_setting('filterorientation')
__sortby__ = plugin.get_setting('sortby')

VIDEOS = json.load(file(os.path.join(__resources__, 'tags.json')))
webreq = simpleutils.CachedWebRequest(cookiePath=os.path.join(xbmc.translatePath('special://profile'), 'addon_data/', plugin.id))
revidblock = re.compile(ur'<div id="(video_.*?)</p></div>', re.DOTALL)
revidparts = re.compile(ur'video_([\d]+).*? src="(.*?)".*?href="(.*?)".*?itle="(.*?)".*?"duration">[\(](.+?)[\)]</span',re.DOTALL)


def parsepageforvideos(html):
    matches = revidblock.findall(html)
    listitems = []
    for vidhtml in matches:
        vmatches = revidparts.findall(vidhtml)
예제 #23
0
    def test_run(self):
        plugin = Plugin('test.plugin')
        plugin.create_listing = mock.MagicMock()
        plugin.resolve_url = mock.MagicMock()
        plugin._add_directory_items = mock.MagicMock()
        plugin._set_resolved_url = mock.MagicMock()
        mock_actions = mock.MagicMock()
        # Test calling 'root' action
        with mock.patch('simpleplugin.sys.argv', ['test.plugin', '1', '']):
            mock_actions.root.return_value = [{'label': 'root'}]
            plugin.actions['root'] = mock_actions.root
            plugin.run(category='Foo')
            mock_actions.root.assert_called_with({})
            plugin.create_listing.assert_called_with([{'label': 'root'}])
            # Test setting plugin category
            mock_xbmcplugin.setPluginCategory.assert_called_with(1, 'Foo')
        # Test calling a child action returning list or generator
        with mock.patch('simpleplugin.sys.argv',
                        ['test.plugin', '1', '?action=foo&param=bar']):
            plugin.create_listing.reset_mock()
            mock_actions.foo.return_value = [{'label': 'foo'}]
            plugin.actions['foo'] = mock_actions.foo
            plugin.run()
            mock_actions.foo.assert_called_with({
                'action': 'foo',
                'param': 'bar'
            })
            plugin.create_listing.assert_called_with([{'label': 'foo'}])
            plugin.create_listing.reset_mock()
            generator = test_generator()
            mock_actions.foo.return_value = generator
            plugin.run()
            mock_actions.foo.assert_called_with({
                'action': 'foo',
                'param': 'bar'
            })
            plugin.create_listing.assert_called_with(generator)
        # Test calling a child action returning a str
        with mock.patch('simpleplugin.sys.argv',
                        ['test.plugin', '1', '?action=play_str']):
            mock_actions.play_str.return_value = '/play/path'
            plugin.actions['play_str'] = mock_actions.play_str
            plugin.run()
            plugin.resolve_url.assert_called_with('/play/path')
        # Test calling a child action returning ListContext namedtuple
        with mock.patch('simpleplugin.sys.argv',
                        ['test.plugin', '1', '?action=tuple_listing']):
            plugin._add_directory_items.reset_mock()
            list_context = ListContext([{
                'url': 'plugin://foo',
                'label': 'Foo',
                'is_folder': True
            }], True, True, True, (0, ), 50, 'movies')

            mock_actions.dict_listing.return_value = list_context
            plugin.actions['tuple_listing'] = mock_actions.dict_listing
            plugin.run()
            plugin._add_directory_items.assert_called_with(list_context)
        # Test calling a child action returning PlayContext namedtuple
        with mock.patch('simpleplugin.sys.argv',
                        ['test.plugin', '1', '?action=tuple_play']):
            plugin._set_resolved_url.reset_mock()
            play_context = PlayContext('http://foo.bar', None, True)
            mock_actions.dict_play.return_value = play_context
            plugin.actions['tuple_play'] = mock_actions.dict_play
            plugin.run()
            plugin._set_resolved_url.assert_called_with(play_context)
        # Test unregistered action
        with mock.patch('simpleplugin.sys.argv',
                        ['test.plugin', '1', '?action=invalid']):
            self.assertRaises(SimplePluginError, plugin.run)
예제 #24
0
# -*- coding: utf-8 -*-
# Module: main
# Author: Roman V. M.
# Created on: 28.11.2014
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html

from simpleplugin import Plugin

# Create plugin instance
plugin = Plugin()

# Free sample videos are provided by www.vidsplay.com
# Here we use a fixed set of properties simply for demonstrating purposes
# In a "real life" plugin you will need to get info and links to video files/streams
# from some web-site or online service.
VIDEOS = {
    'Animals': [{
        'name': 'Crab',
        'thumb': 'http://www.vidsplay.com/vids/crab.jpg',
        'video': 'http://www.vidsplay.com/vids/crab.mp4'
    }, {
        'name': 'Alligator',
        'thumb': 'http://www.vidsplay.com/vids/alligator.jpg',
        'video': 'http://www.vidsplay.com/vids/alligator.mp4'
    }, {
        'name': 'Turtle',
        'thumb': 'http://www.vidsplay.com/vids/turtle.jpg',
        'video': 'http://www.vidsplay.com/vids/turtle.mp4'
    }],
    'Cars': [{
        'name': 'Postal Truck',
예제 #25
0
import xbmc
import xbmcaddon
import xbmcplugin
import xbmcgui

# Add the /lib folder to sys
sys.path.append(
    xbmc.translatePath(
        os.path.join(
            xbmcaddon.Addon("plugin.video.auvio").getAddonInfo("path"),
            "lib")))

# SimplePlugin
from simpleplugin import Plugin
from simpleplugin import Addon
plugin = Plugin()  # Create plugin instance

rtbf_url = 'http://www.rtbf.be/'
cryo_base_url = rtbf_url + "api/partner/generic/"
cryo_partner_key = '97a0ceb4562f285ba770aaba6c81d047'  #website: 82ed2c5b7df0a9334dfbda21eccd8427
auvio_url = 'http://www.rtbf.be/auvio/'

#in minutes
cachetime_app_settings = 60 * 24
cachetime_media_data = 60 * 24
cachetime_medias_recent = 15


def popup(text, time=5000, image=None):
    title = plugin.addon.getAddonInfo('name')
    icon = plugin.addon.getAddonInfo('icon')
예제 #26
0
import sys, json, os, re, simpleutils
import xbmc, xbmcgui
import urlquick
from simpleplugin import Plugin, Params
try:
    from urllib import quote_plus, urlencode
except:
    from urllib import parse
    quote_plus = parse.quote_plus
try:
    from operator import itemgetter
except:
    import operator
    itemgetter = operator.itemgetter

plugin = Plugin()  # Get the plugin url in plugin:// notation. plugin
_url = sys.argv[0]  # Get the plugin handle as an integer number.
_handle = int(sys.argv[1])
__addondir__ = xbmc.translatePath(plugin.addon.getAddonInfo('path'))
__resources__ = os.path.join(__addondir__, 'resources/')
__next__ = os.path.join(__resources__, "next.png")
__filtersex__ = 'gay'
__sortby__ = 'hits'
__period__ = 'ever'

VIDEOS = json.load(file(os.path.join(__resources__, 'tags.json')))
webreq = simpleutils.CachedWebRequest(cookiePath=os.path.join(
    xbmc.translatePath('special://profile'), 'addon_data/', plugin.id))
revidblock = re.compile(ur'<div id="(video_.*?)</p></div>', re.DOTALL)
reGetvids = re.compile(ur'href="(.+?)".*?data-src="(.+?)".*?title="(.+?)"')
예제 #27
0
import hashlib
import os
import shutil
import sys

from BeautifulSoup import BeautifulSoup
import requests
from requests.exceptions import HTTPError
from simpleplugin import Plugin
import xbmc
import xbmcgui

plugin = Plugin()
_ = plugin.initialize_gettext()

SHOWS_CACHE = os.path.join(plugin.config_dir, 'shows')
if not os.path.exists(SHOWS_CACHE):
    os.mkdir(SHOWS_CACHE)

BASE_URL = 'https://www.byte.fm'

ARCHIVE_BASE_URL = 'http://archiv.byte.fm'

LETTERS = '0ABCDEFGHIJKLMNOPQRSTUVWXYZ'

PLUGIN_NAME = 'plugin.audio.bytefm'

CHUNK_SIZE = 1024 * 1024  # 1MB

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
예제 #28
0
# Licence:     GPL v.3: http://www.gnu.org/copyleft/gpl.html

# This plugin uses my SimplePlugin library:
# https://github.com/romanvm/script.module.simpleplugin

import os
import urllib
from collections import namedtuple
import xbmc
import xbmcgui
from simpleplugin import Plugin
import exua
import webclient
import login_window

plugin = Plugin()
icons = os.path.join(plugin.path, 'resources', 'icons')
_ = plugin.initialize_gettext()

SearchQuery = namedtuple('SearchQuery', ['query', 'path'])
dialog = xbmcgui.Dialog()


def _media_categories(categories, content):
    """
    Create media categories listing
    """
    for category in categories:
        yield {
            'label': u'{0} [COLOR=gray][{1}][/COLOR]'.format(category.name, category.items),
            'url': plugin.get_url(action='media_list', path=category.path, page='0'),
예제 #29
0
import json
import shutil
import dateutil.parser
from datetime import datetime

# Add the /lib folder to sys
sys.path.append(xbmc.translatePath(os.path.join(xbmcaddon.Addon("plugin.audio.subsonic").getAddonInfo("path"), "lib")))


import libsonic_extra #TO FIX - we should get rid of this and use only libsonic

from simpleplugin import Plugin
from simpleplugin import Addon

# Create plugin instance
plugin = Plugin()

# initialize_gettext
#_ = plugin.initialize_gettext()

connection = None
cachetime = int(Addon().get_setting('cachetime'))

def popup(text, time=5000, image=None):
    title = plugin.addon.getAddonInfo('name')
    icon = plugin.addon.getAddonInfo('icon')
    xbmc.executebuiltin('Notification(%s, %s, %d, %s)' % (title, text,
                        time, icon))

def get_connection():
    global connection
예제 #30
0
# -*- coding: utf-8 -*-

import re
from urllib import quote_plus, unquote, urlencode
from urlparse import parse_qs, urlparse
from xml.etree import ElementTree

import requests

import xbmc
from xbmcplugin import setContent
from resources.lib.api import Streamy, fetchapi, torapi
from resources.lib.notify import OverlayText
from simpleplugin import Plugin

app = Plugin()
streamy = Streamy(app.get_setting('server'))


def search_ui():
    keyboard = xbmc.Keyboard('', 'Search')
    keyboard.doModal()
    if keyboard.isConfirmed():
        return keyboard.getText()


def search_trailer(title):
    title = quote_plus(title)
    return 'Container.Update(plugin://plugin.video.youtube/kodion/search/query/?q={})'.format(
        title)
예제 #31
0
from simpleplugin import Plugin
import xbmc
import xbmcaddon
import json
from api import VideoAPIClass

ADDON = xbmcaddon.Addon()
ADDON_ID = ADDON.getAddonInfo('id')
ADDON_ICON = ADDON.getAddonInfo('icon')
ADDON_NAME = ADDON.getAddonInfo('name')
ADDON_PATH = ADDON.getAddonInfo('path').decode("utf-8")
ADDON_VERSION = ADDON.getAddonInfo('version')
ADDON_DATA_PATH = xbmc.translatePath("special://profile/addon_data/%s" %
                                     ADDON_ID).decode("utf-8")

plugin = Plugin()
VIDEOAPI = VideoAPIClass()


@plugin.action()
def pptv_play(params):
    if not xbmc.getCondVisibility('system.platform.Android'):
        xbmc.Player().play("C:/Download/20160810-111059351.mkv", windowed=True)
        xbmc.executebuiltin("ActivateWindow(fullscreenvideo)")
        return
    cid = params.cid
    vid = params.vid
    json_query = {
        "cmp": {
            "pkg": "com.pptv.ott.sdk",
            "class": "com.pptv.ott.sdk.PlayerActivity"
예제 #32
0
from simpleplugin import Plugin
from web_client import load_page
from rarbg_exceptions import RarbgApiError
import os, re
import bs4, time
import requests
import xbmcvfs
from bs4 import BeautifulSoup
import re, sqlite3
import urllib2
import xbmcgui

__all__ = ['load_torrents']

API = 'http://torrentapi.org/pubapi_v2.php'
plugin = Plugin('plugin.video.rk.tv')


def get_token():
    """
    Get a token to access Rarbg API

    The token will expire in 15 min

    :return: Rarbg API token
    :rtype: str
    """
    params = {'get_token': 'get_token'}
    return load_page(API,
                     params=params,
                     headers={'content-type': 'application/json'})['token']