-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.py
102 lines (92 loc) · 3.88 KB
/
default.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# -*- coding: UTF-8 -*-
# /*
# * Copyright (C) 2013 Maros Ondrasek
# *
# *
# * This Program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2, 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; see the file COPYING. If not, write to
# * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# * http://www.gnu.org/copyleft/gpl.html
# *
# */
import os
sys.path.append(os.path.join (os.path.dirname(__file__), 'resources', 'lib'))
import gordonura
import xbmcprovider, xbmcaddon, xbmcutil, xbmc, xbmcgui
import util, resolver
from provider import ResolveException
__scriptid__ = 'plugin.video.gordon.ura.cz'
__scriptname__ = 'gordon.ura.cz'
__addon__ = xbmcaddon.Addon(id=__scriptid__)
__language__ = __addon__.getLocalizedString
def vp8_youtube_filter(stream):
# some embedded devices running xbmc doesnt have vp8 support, so we
# provide filtering ability for youtube videos
#======================================================================
# 5: "240p h263 flv container",
# 18: "360p h264 mp4 container | 270 for rtmpe?",
# 22: "720p h264 mp4 container",
# 26: "???",
# 33: "???",
# 34: "360p h264 flv container",
# 35: "480p h264 flv container",
# 37: "1080p h264 mp4 container",
# 38: "720p vp8 webm container",
# 43: "360p h264 flv container",
# 44: "480p vp8 webm container",
# 45: "720p vp8 webm container",
# 46: "520p vp8 webm stereo",
# 59: "480 for rtmpe",
# 78: "seems to be around 400 for rtmpe",
# 82: "360p h264 stereo",
# 83: "240p h264 stereo",
# 84: "720p h264 stereo",
# 85: "520p h264 stereo",
# 100: "360p vp8 webm stereo",
# 101: "480p vp8 webm stereo",
# 102: "720p vp8 webm stereo",
# 120: "hd720",
# 121: "hd1080"
#======================================================================
try:
if stream['fmt'] in [38, 44, 43, 45, 46, 100, 101, 102]:
return True
except KeyError:
return False
return False
class GordonUraXBMCContentProvider(xbmcprovider.XBMCMultiResolverContentProvider):
def resolve(self, url):
def select_cb(resolved):
if __addon__.getSetting('filter_vp8') == 'true':
resolved = [r for r in resolved if not vp8_youtube_filter(r)]
quality = self.settings['quality'] or '0'
resolved = resolver.filter_by_quality(resolved,quality)
# if user requested something but 'ask me' or filtered result is exactly 1
if len(resolved) == 1 or int(quality) > 0:
return resolved[0]
dialog = xbmcgui.Dialog()
ret = dialog.select(xbmcutil.__lang__(30005), ['%s [%s]'%(r['title'],r['quality']) for r in resolved])
if ret >= 0:
return resolved[ret]
item = self.provider.video_item()
item.update({'url':url})
try:
return self.provider.resolve(item,select_cb=select_cb)
except ResolveException, e:
self._handle_exc(e)
settings = {'downloads':__addon__.getSetting('downloads'), 'quality':__addon__.getSetting('quality')}
params = util.params()
if params=={}:
xbmcutil.init_usage_reporting(__scriptid__)
provider = gordonura.GordonUraContentProvider()
GordonUraXBMCContentProvider(provider, settings, __addon__).run(params)