-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwindow_channels.py
123 lines (93 loc) · 4.2 KB
/
window_channels.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# -*- coding: utf-8 -*-
#------------------------------------------------------------
# pelisalacarta 4
# Copyright 2015 [email protected]
#
# Distributed under the terms of GNU General Public License v3 (GPLv3)
# http://www.gnu.org/licenses/gpl-3.0.html
#------------------------------------------------------------
# This file is part of pelisalacarta 4.
#
# pelisalacarta 4 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 3 of the License, or
# (at your option) any later version.
#
# pelisalacarta 4 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 pelisalacarta 4. If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------
import os
import sys
import urlparse,urllib,urllib2
import xbmc
import xbmcgui
import xbmcaddon
from windowtools import *
import plugintools
import navigation
from core.item import Item
class ChannelWindow(xbmcgui.WindowXML):
def __init__(self, xml_name, fallback_path):
plugintools.log("ChannelWindow.__init__ xml_name="+xml_name+" fallback_path="+fallback_path)
self.first_time = False
self.itemlist = []
def setParentItem(self,item):
self.parent_item = item
def setItemlist(self,itemlist):
plugintools.log("ChannelWindow.setItemlist")
for item in itemlist:
plugintools.log("ChannelWindow.setItemlist item="+item.tostring())
self.itemlist.append(item)
def onInit( self ):
plugintools.log("ChannelWindow.onInit")
if self.first_time == True:
return
self.first_time = True
self.control_list = self.getControl(100)
for item in self.itemlist:
list_item = xbmcgui.ListItem( item.title , iconImage=item.thumbnail, thumbnailImage=item.thumbnail)
info_labels = { "Title" : item.title, "FileName" : item.title, "Plot" : item.plot }
list_item.setInfo( "video", info_labels )
if item.fanart!="":
list_item.setProperty('fanart_image',item.fanart)
self.control_list.addItem(list_item)
self.setFocusId(100)
def onAction(self, action):
plugintools.log("ChannelWindow.onAction action.id="+repr(action.getId())+" action.buttonCode="+repr(action.getButtonCode()))
if action == ACTION_PARENT_DIR or action==ACTION_PREVIOUS_MENU or action==ACTION_PREVIOUS_MENU2:
self.close()
if action == ACTION_SELECT_ITEM:
loader_image = os.path.join( plugintools.get_runtime_path(), 'resources', 'skins', 'Default', 'media', 'loader.gif')
loader = xbmcgui.ControlImage(1200, 19, 40, 40, loader_image)
self.addControl(loader)
pos = self.control_list.getSelectedPosition()
item = self.itemlist[pos]
if item.action.startswith("play_"):
play_items = navigation.get_next_items( item )
loader.setVisible(False)
media_url = play_items[0].url
plugintools.direct_play(media_url)
else:
next_items = navigation.get_next_items( item )
loader.setVisible(False)
# Si no hay nada, no muestra la pantalla vacía
if len(next_items)>0:
next_window = navigation.get_window_for_item( item )
next_window.setItemlist(next_items)
next_window.setParentItem(item)
next_window.doModal()
del next_window
def onFocus( self, control_id ):
plugintools.log("ChannelWindow.onFocus "+repr(control_id))
pass
def onClick( self, control_id ):
plugintools.log("ChannelWindow.onClick "+repr(control_id))
pass
def onControl(self, control):
plugintools.log("ChannelWindow.onClick "+repr(control))
pass