本文整理汇总了Python中xbmcswift2.Plugin类的典型用法代码示例。如果您正苦于以下问题:Python Plugin类的具体用法?Python Plugin怎么用?Python Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestParseRequest
class TestParseRequest(TestCase):
def setUp(self):
name = "Hello XBMC"
plugin_id = "plugin.video.helloxbmc"
path = os.path.join(os.path.dirname(__file__), "data", "plugin", "addon.py")
with preserve_cwd(os.path.dirname(path)):
self.plugin = Plugin(name, plugin_id, path)
def test_parse_request(self):
with patch("xbmcswift2.plugin.Request") as MockRequest:
sys.argv = ["plugin://plugin.video.helloxbmc", "0", "?"]
self.plugin._parse_request()
MockRequest.assert_called_with("plugin://plugin.video.helloxbmc?", "0")
def test_parse_request_no_qs(self):
with patch("xbmcswift2.plugin.Request") as MockRequest:
sys.argv = ["plugin://plugin.video.helloxbmc", "0"]
self.plugin._parse_request()
MockRequest.assert_called_with("plugin://plugin.video.helloxbmc", "0")
def test_parse_request_path_in_arg0(self):
# Older versions of xbmc sometimes pass path in arg0
with patch("xbmcswift2.plugin.Request") as MockRequest:
sys.argv = ["plugin://plugin.video.helloxbmc/videos/", "0", "?foo=bar"]
self.plugin._parse_request()
MockRequest.assert_called_with("plugin://plugin.video.helloxbmc/videos/?foo=bar", "0")
def test_parse_request_path_in_arg2(self):
# Older versions of xbmc sometimes pass path in arg2
with patch("xbmcswift2.plugin.Request") as MockRequest:
sys.argv = ["plugin://plugin.video.helloxbmc", "0", "/videos/?foo=bar"]
self.plugin._parse_request()
MockRequest.assert_called_with("plugin://plugin.video.helloxbmc/videos/?foo=bar", "0")
示例2: __init__
def __init__(self):
self.plugin = Plugin()
self.plugin.register_module(menu.Module(), '')
self.plugin.register_module(showlist.Module(), '')
self.plugin.register_module(playlist.Module(), '')
self.plugin.register_module(videolist.Module(), '')
self.plugin.register_module(play.Module(), '')
self.utils = Utils(self.plugin)
self.utils.log_init()
示例3: __init__
def __init__(self, addon_dir=None):
self.addon_dir = addon_dir
self.plugin = Plugin()
self.plugin.register_module(menu.Module(), '')
self.plugin.register_module(showlist.Module(), '')
self.plugin.register_module(playlist.Module(), '')
self.plugin.register_module(videolist.Module(), '')
self.plugin.register_module(play.Module(), '')
self.utils = Utils(self.plugin, addon_dir=self.addon_dir)
self.utils.log_init()
示例4: Plugin
from xbmcswift2 import Plugin, xbmcgui
import resources.lib.util as util
from resources.lib.abc_base import BaseI4M
from resources.lib.sites import *
import urllib
plugin = Plugin()
STRINGS = {
'url_resolver_settings': 30100,
'try_again': 30050,
'site_unavailable': 30051,
'is_unavailable': 30052,
'try_again_later': 30053,
'no_valid_links': 30057,
'cannot_play': 30058,
'no_search_terms': 30060,
'video_url_not_found': 30061,
'unresolvable_link': 30062
}
def _(string_id):
if string_id in STRINGS:
return plugin.get_string(STRINGS[string_id])
else:
plugin.log.warning('String is missing: %s' % string_id)
return string_id
示例5: Plugin
from xbmcswift2 import Plugin
import xbmc,xbmcaddon,xbmcvfs,xbmcgui
import re
import requests
import resources.lib.pytz
from resources.lib.pytz import timezone
import datetime
plugin = Plugin()
def log2(v):
xbmc.log(repr(v))
def log(v):
xbmc.log(re.sub(',',',\n',repr(v)))
def get_tvdb_id(name):
tvdb_url = "http://thetvdb.com//api/GetSeries.php?seriesname=%s" % name
r = requests.get(tvdb_url)
tvdb_html = r.text
tvdb_id = ''
tvdb_match = re.search(r'<seriesid>(.*?)</seriesid>', tvdb_html, flags=(re.DOTALL | re.MULTILINE))
if tvdb_match:
tvdb_id = tvdb_match.group(1)
return tvdb_id
@plugin.route('/play/<channel>/<title>/<season>/<episode>')
def play(channel,title,season,episode):
示例6: Plugin
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
from xbmcswift2 import Plugin
# global declarations
# plugin stuff
plugin = Plugin()
class PluginInformation:
name = plugin.name
version = plugin.addon.getAddonInfo('version')
# settings stuff
languages = ['fr', 'de', 'en', 'es', 'pl']
qualities = ['SQ', 'EQ', 'HQ']
# defaults to fr
language = plugin.get_setting('lang', choices=languages) or languages[0]
# defaults to SQ
quality = plugin.get_setting('quality', choices=qualities) or qualities[0]
示例7: Plugin
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os.path as path
import json
import re
import urllib
from urllib import quote_plus
import ssl
import requests
from unidecode import unidecode
import webutil as WebUtils
from xbmcswift2 import Plugin, xbmc, ListItem, download_page, clean_dict, SortMethod
plugin = Plugin()
ssl._create_default_https_context = ssl._create_unverified_context
__BASEURL__ = u'https://watchseries-online.pl'
__addondir__ = xbmc.translatePath(plugin.addon.getAddonInfo('path'))
__datadir__ = xbmc.translatePath('special://profile/addon_data/{0}/'.format(plugin.id))
__cookie__ = path.join(__datadir__, 'cookies.lwp')
__temp__ = path.join(__datadir__, 'temp/')
__resdir__ = path.join(__addondir__, 'resources')
__imgsearch__ = path.join(__resdir__, 'search.png')
__savedjson__ = path.join(xbmc.translatePath(plugin.addon.getAddonInfo('profile')), 'savedshows.json')
getWeb = WebUtils.CachedWebRequest(path.join(__datadir__, 'cookies.lwp'), __temp__)
#getWeb = WebUtils.BaseRequest(path.join(__datadir__, 'cookies.lwp'))
def loadsaved():
sitems = []
litems = []
items = []
示例8: Plugin
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from xbmcswift2 import Plugin
from resources.lib.api import Api, ApiError
plugin = Plugin()
api = Api(logger=plugin.log)
@plugin.route('/')
def show_root_menu():
items = [
{
'label': station.name,
'path': plugin.url_for('play', api_id=station.api_id),
}
for station in api.get_stations()
]
return plugin.finish(items)
示例9: Plugin
from xbmcswift2 import Plugin, xbmcgui
from resources.lib.api import SiteApi
plugin = Plugin()
api = SiteApi()
@plugin.cached_route("/")
def index():
"""
Get movie categories
"""
plugin.log.debug("Get category menu")
c = api.get_menu_category()
items = [
{
"label": item["label"],
"path": plugin.url_for("browse_category", menuid=item.get("pk", "0"), page=1, url=item["url"]),
}
for item in c
]
return items
@plugin.cached_route("/<menuid>/page/<page>")
def browse_category(menuid, page="1"):
"""
示例10: Plugin
from xbmcswift2 import Plugin, xbmc
from settings import SETTING_LANGUAGE_ID
plugin = Plugin()
if plugin.get_setting(SETTING_LANGUAGE_ID, converter=str) == "system": LANG = xbmc.getLanguage(xbmc.ISO_639_1,)
else: LANG = plugin.get_setting(SETTING_LANGUAGE_ID, converter=str)
def import_tmdb():
""" Lazy import tmdb """
import tmdbsimple
__builtins__["tmdb"] = tmdbsimple
def import_tvdb():
""" Lazy import tmdb """
if 'tvdb' not in __builtins__:
__builtins__['tvdb'] = create_tvdb()
def create_tvdb(language=LANG):
from tvdb_api import Tvdb
return Tvdb("0629B785CE550C8D", language=language, cache=plugin.storage_path)
示例11: Plugin
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from xbmcswift2 import Plugin
from resources.lib.api import NetzkinoApi, NetworkError
plugin = Plugin()
api = NetzkinoApi()
@plugin.route('/')
def show_categories():
categories = api.get_categories()
items = [{
'label': item['title'],
'path': plugin.url_for(
endpoint='show_movies',
category_id=str(item['id'])
)
} for item in categories]
return plugin.finish(items)
示例12: Plugin
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from xbmcswift2 import Plugin, xbmc
from resources.lib.api import ShoutcastApi, NetworkError
plugin = Plugin()
api = ShoutcastApi('sh1t7hyn3Kh0jhlV')
my_stations = plugin.get_storage('my_stations.json', file_format='json')
STRINGS = {
'all': 30000,
'top500_stations': 30001,
'browse_by_genre': 30002,
'my_stations': 30003,
'search_station': 30004,
'search_current_track': 30005,
'add_to_my_stations': 30010,
'remove_from_my_stations': 30011,
'network_error': 30200
}
示例13: Plugin
Reddit Music
~~~~~~~~~~~~
An XBMC addon for watching and listenting to music found on a variety of
subreddits.
:copyright: (c) 2012 by Jonathan Beluch
:license: GPLv3, see LICENSE.txt for more details.
'''
import operator
from xbmcswift2 import Plugin
from resources.lib.subreddits import subreddits
from resources.lib import mediahosts, playlists, reddit
plugin = Plugin()
plugin.register_module(playlists.playlists, '/playlists')
red = reddit.Reddit(user_agent='XBMC')
STRINGS = {
'browse_subreddits': 30010,
'my_playlists': 30011,
'add_to_playlist': 30012,
}
def _(string_id):
return plugin.get_string(STRINGS[string_id])
示例14: Plugin
import xbmc
import xbmcaddon
import xbmcgui
import datetime
import urlparse
import urllib2
import re
import HTMLParser
import codecs
# The following modules require an import entry in the addon.xml.
import urlresolver.types
from xbmcswift2 import Plugin
from bs4 import BeautifulSoup
plugin = Plugin()
MYNAME = "Movie4k.to"
CACHE_TTL = 360 # 6 hours
THUMBNAIL_PATH = os.path.join( plugintools.get_runtime_path() , "resources" , "img" )
FANART = os.path.join( plugintools.get_runtime_path() , "fanart.jpg" )
FORUM_URL = 'http://forums.tvaddons.ag'
plugintools.module_log_enabled = (plugintools.get_setting("debug")=="true")
plugintools.http_debug_log_enabled = (plugintools.get_setting("debug")=="true")
HOSTERS_BLACKLIST = [] # ["filenuke", "divxstage", "streamclou", "xvidstage", "rapidvideo"]
if plugintools.get_setting("use_anonymizer_site")=="true":
ANON_URL = 'http://anonymouse.org/cgi-bin/anon-www.cgi/'
MAIN_URL = ANON_URL + 'http://www.movie4k.to/'
elif plugintools.get_setting("use_alternative_site_url")=="true":
MAIN_URL = plugintools.get_setting("alternative_site_url")
示例15: Plugin
# -*- coding: utf-8 -*-
"""
Dabdate - Korea Drama/TV Shows Streaming Service
"""
from xbmcswift2 import Plugin, actions
import xbmcvfs
import os
import json
plugin = Plugin()
_L = plugin.get_string
plugin_path = plugin.addon.getAddonInfo('path')
lib_path = os.path.join(plugin_path, 'resources', 'lib')
sys.path.append(lib_path)
vidmap = None
import dabdate
vidmap_path = plugin.get_setting('vidmap_path', str)
print vidmap_path
if vidmap_path:
try:
f = xbmcvfs.File(vidmap_path)
vidmap = json.load(f)
f.close()
plugin.log.info("direct play is enabled with "+vidmap_path)
except:
vidmap = None
qualcode = {
'' :'1', # default