[0dea54]: plugin.program.super.favourites / capture.py  Maximize  Restore  History

Download this file

219 lines (168 with data), 6.7 kB

  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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#
# Copyright (C) 2014
# Sean Poyser (seanpoyser@gmail.com)
#
# 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 XBMC; 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 xbmc
import xbmcgui
_STD_SETTINGS = 0
_ADDTOFAVES = 100
_SF_SETTINGS = 200
_LAUNCH_SF = 300
_SEARCH = 400
_DOWNLOAD = 500
_PLAYLIST = 600
def doStandard():
window = xbmcgui.getCurrentWindowId()
if window == 12005: #video playing
xbmc.executebuiltin('ActivateWindow(videoplaylist)')
return
xbmc.executebuiltin('XBMC.Action(ContextMenu)')
def copyFave(name, thumb, cmd):
import favourite
import utils
text = utils.GETTEXT(30019)
folder = utils.GetFolder(text)
if not folder:
return False
file = os.path.join(folder, utils.FILENAME)
faves = favourite.getFavourites(file)
#if it is already in there don't add again
for fave in faves:
if fave[2] == cmd:
return False
fave = [name, thumb, cmd]
faves.append(fave)
favourite.writeFavourites(file, faves)
return True
def activateCommand(cmd):
cmds = cmd.split(',', 1)
activate = cmds[0]+',return)'
plugin = cmds[1][:-1]
#check if it is a different window and if so activate it
id = str(xbmcgui.getCurrentWindowId())
if id not in activate:
xbmc.executebuiltin(activate)
xbmc.executebuiltin('Container.Update(%s)' % plugin)
def doMenu():
try:
import utils
except:
doStandard()
return
import contextmenu
# to prevent master profile setting being used in other profiles
if utils.ADDON.getSetting('CONTEXT') != 'true':
doStandard()
return
folder = xbmc.getInfoLabel('Container.FolderPath')
#ignore if in Super Favourites
if utils.ADDONID in folder:
doStandard()
return
choice = 0
label = xbmc.getInfoLabel('ListItem.Label')
path = xbmc.getInfoLabel('ListItem.FolderPath')
filename = xbmc.getInfoLabel('ListItem.FilenameAndPath')
name = xbmc.getInfoLabel('ListItem.Label')
thumb = xbmc.getInfoLabel('ListItem.Thumb')
window = xbmcgui.getCurrentWindowId()
playable = xbmc.getInfoLabel('ListItem.Property(IsPlayable)').lower() == 'true'
fanart = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)')
isFolder = xbmc.getCondVisibility('ListItem.IsFolder') == 1
try: file = xbmc.Player().getPlayingFile()
except: file = None
isStream = False
if file:
isStream = file.startswith('http://')
#GOTHAM only
#if hasattr(xbmc.Player(), 'isInternetStream'):
# isStream = xbmc.Player().isInternetStream()
#elif file:
# isStream = file.startswith('http://')
#print '**** Context Menu Information ****'
#print 'Label : %s' % label
#print 'Folder : %s' % folder
#print 'Path : %s' % path
#print 'Filename : %s' % filename
#print 'Name : %s' % name
#print 'Thumb : %s' % thumb
#print 'Fanart : %s' % fanart
#print 'Window : %d' % window
#print 'IsPlayable : %s' % playable
#print 'IsFolder : %s' % isFolder
#print 'File : %s' % file
#print 'IsStream : %s' % isStream
menu = []
if (len(menu) == 0) and window == 12005: #video playing
if isStream:
menu.append(('Download %s' % label , _DOWNLOAD))
menu.append(('Show Playlist', _PLAYLIST))
else:
return doStandard()
#cancel download feature for now
return doStandard()
if (len(menu) == 0) and len(path) > 0:
utils.verifySuperSearch()
menu.append((utils.GETTEXT(30047), _ADDTOFAVES))
menu.append((utils.GETTEXT(30049), _SF_SETTINGS))
menu.append((utils.GETTEXT(30054), _SEARCH))
menu.append((utils.GETTEXT(30048), _STD_SETTINGS))
#elif window == 10000: #Home screen
# menu.append((utils.GETTEXT(30053), _LAUNCH_SF))
# menu.append((utils.GETTEXT(30049), _SF_SETTINGS))
if len(menu) == 0:
doStandard()
return
xbmcgui.Window(10000).setProperty('SF_MENU_VISIBLE', 'true')
choice = contextmenu.showMenu(utils.ADDONID, menu)
if choice == _PLAYLIST:
xbmc.executebuiltin('ActivateWindow(videoplaylist)')
if choice == _DOWNLOAD:
import download
download.download(file, 'c:\\temp\\file.mpg', 'Super Favourites')
if choice == _STD_SETTINGS:
xbmc.executebuiltin('XBMC.Action(ContextMenu)')
if choice == _SF_SETTINGS:
utils.ADDON.openSettings()
if choice == _ADDTOFAVES:
if isFolder:
cmd = 'ActivateWindow(%d,"%s")' % (window, path)
elif path.lower().startswith('script'):
if path[-1] == '/':
path = path[:-1]
cmd = 'RunScript("%s")' % path.replace('script://', '')
elif path.lower().startswith('videodb') and len(filename) > 0:
cmd = 'PlayMedia("%s")' % filename
#elif path.lower().startswith('musicdb') and len(filename) > 0:
# cmd = 'PlayMedia("%s")' % filename
else:
cmd = 'PlayMedia("%s&sf_win_id=%d_")' % (path, window)
copyFave(name, thumb, cmd)
if choice == _LAUNCH_SF:
xbmc.executebuiltin('ActivateWindow(programs,plugin://%s)' % utils.ADDONID)
if choice == _SEARCH:
thumb = thumb if len(thumb) > 0 else 'null'
fanart = fanart if len(fanart) > 0 else 'null'
import urllib
_SUPERSEARCH = 0 #declared as 0 in default.py
winID = 10025 #video
cmd = 'ActivateWindow(%d,"plugin://%s/?mode=%d&keyword=%s&image=%s&fanart=%s")' % (window, utils.ADDONID, _SUPERSEARCH, urllib.quote_plus(name), urllib.quote_plus(thumb), urllib.quote_plus(fanart))
activateCommand(cmd)
if xbmcgui.Window(10000).getProperty('SF_MENU_VISIBLE') != 'true':
doMenu()
xbmcgui.Window(10000).clearProperty('SF_MENU_VISIBLE')

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks