Skip to content

Commit

Permalink
Merge branch 'stable-pre'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasonra committed Mar 25, 2012
2 parents aefbea4 + 2a59087 commit 6696b49
Show file tree
Hide file tree
Showing 35 changed files with 3,486 additions and 448 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon
id="script.pseudotv"
version="2.0.0"
version="2.1.0"
name="PseudoTV"
provider-name="Jason Anderson">

Expand Down
16 changes: 16 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Changelog


2.1.0
New rule: reset every x days
Update to Night skin (thanks Steveb).
Better exception handling.
Change 'short clip' length.
Include IceLibrary streams.
Configuration bug fixes.
Addition of Metropolis skin (thanks Steveb).
Updates to skins (thanks again Steveb).
Fix for color truncation (thanks Josebiro).
Fix for missing texture (thanks lambda81).
Hide channel bug when changing channel.
Properly detect already running.
Option to include the season / episode in the show title.


2.0.0
New advanced channel rule system.
Share channels between multiple systems.
Expand Down
4 changes: 3 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def onFocus(self, controlId):
def onAction(self, act):
action = act.getId()

if action == ACTION_PREVIOUS_MENU:
if action in ACTION_PREVIOUS_MENU:
if self.showingList == False:
self.cancelChan()
self.hideChanDetails()
Expand Down Expand Up @@ -118,6 +118,8 @@ def saveSettings(self):

if self.getControl(194).isSelected():
ADDON_SETTINGS.setSetting(setting2, str(MODE_ORDERAIRDATE))
else:
ADDON_SETTINGS.setSetting(setting2, "0")
elif chantype == 7:
ADDON_SETTINGS.setSetting(setting1, self.getControl(200).getLabel())
elif chantype == 9999:
Expand Down
41 changes: 7 additions & 34 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,34 @@
# You should have received a copy of the GNU General Public License
# along with PseudoTV. If not, see <http://www.gnu.org/licenses/>.

import sys
import os, threading

import xbmc, xbmcgui
import xbmcaddon

from resources.lib.Globals import *



# Script constants
__scriptname__ = "PseudoTV"
__author__ = "Jason102"
__url__ = "http://github.com/Jasonra/XBMC-PseudoTV"
__version__ = VERSION
__settings__ = xbmcaddon.Addon(id='script.pseudotv')
__language__ = __settings__.getLocalizedString
__cwd__ = __settings__.getAddonInfo('path')


import resources.lib.Overlay as Overlay


# Adapting a solution from ronie (http://forum.xbmc.org/showthread.php?t=97353)
if xbmc.getInfoLabel("Window(10000).Property(PseudoTVRunning)") != "True":
xbmcgui.Window(10000).setProperty("PseudoTVRunning", "True")
if xbmcgui.Window(10000).getProperty("PseudoTVRunning") != "True":
xbmcgui.Window(10000).setProperty("PseudoTVRunning", "True")
shouldrestart = False

if xbmc.executehttpapi("GetGuiSetting(1, services.webserver)")[4:] == "False":
try:
forcedserver = REAL_SETTINGS.getSetting("ForcedWebServer") == "True"
forcedserver = __settings__.getSetting("ForcedWebServer") == "True"
except:
forcedserver = False

if forcedserver == False:
dlg = xbmcgui.Dialog()
retval = dlg.yesno('PseudoTV', 'PseudoTV will run more efficiently with the web', 'server enabled. Would you like to turn it on?')
REAL_SETTINGS.setSetting("ForcedWebServer", "True")
__settings__.setSetting("ForcedWebServer", "True")

if retval:
xbmc.executehttpapi("SetGUISetting(3, services.webserverport, 8152)")
Expand All @@ -62,24 +53,6 @@
shouldrestart = True

if shouldrestart == False:
MyOverlayWindow = Overlay.TVOverlay("script.pseudotv.TVOverlay.xml", __cwd__, "default")

for curthread in threading.enumerate():
try:
log("Active Thread: " + str(curthread.name), xbmc.LOGERROR)

if curthread.name != "MainThread":
try:
curthread.join()
except:
pass

log("Joined " + curthread.name)
except:
pass

del MyOverlayWindow

xbmcgui.Window(10000).setProperty("PseudoTVRunning", "False")
xbmc.executebuiltin('RunScript("' + __cwd__ + '/pseudotv.py' + '")')
else:
xbmc.log('script.PseudoTV - Already running, exiting')
xbmc.log('script.PseudoTV - Already running, exiting', xbmc.LOGERROR)
59 changes: 59 additions & 0 deletions pseudotv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright (C) 2011 Jason Anderson
#
#
# This file is part of PseudoTV.
#
# PseudoTV 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.
#
# PseudoTV 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 PseudoTV. If not, see <http://www.gnu.org/licenses/>.

import sys
import os, threading
import xbmc, xbmcgui
import xbmcaddon

from resources.lib.Globals import *



# Script constants
__scriptname__ = "PseudoTV"
__author__ = "Jason102"
__url__ = "http://github.com/Jasonra/XBMC-PseudoTV"
__version__ = VERSION
__settings__ = xbmcaddon.Addon(id='script.pseudotv')
__language__ = __settings__.getLocalizedString
__cwd__ = __settings__.getAddonInfo('path')


import resources.lib.Overlay as Overlay


MyOverlayWindow = Overlay.TVOverlay("script.pseudotv.TVOverlay.xml", __cwd__, "default")

for curthread in threading.enumerate():
try:
log("Active Thread: " + str(curthread.name), xbmc.LOGERROR)

if curthread.name != "MainThread":
try:
curthread.join()
except:
pass

log("Joined " + curthread.name)
except:
pass

del MyOverlayWindow
xbmcgui.Window(10000).setProperty("PseudoTVRunning", "False")

3 changes: 3 additions & 0 deletions resources/language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
<string id="30015">Enable Channel Sharing</string>
<string id="30016">Show Coming Up Next box</string>
<string id="30017">Hide very short videos</string>
<string id="30018">Duration of "short" videos</string>
<string id="30019">Include IceLibrary Videos</string>
<string id="30020">Visuals</string>
<string id="30021">Show Season / Episode</string>
</strings>
6 changes: 3 additions & 3 deletions resources/lib/AdvancedConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def __init__(self, *args, **kwargs):
self.allRules = RulesList()


def log(self, msg):
log('AdvancedConfig: ' + msg)
def log(self, msg, level = xbmc.LOGDEBUG):
log('AdvancedConfig: ' + msg, level)


def onInit(self):
Expand Down Expand Up @@ -72,7 +72,7 @@ def onAction(self, act):
if focusid >= 160:
self.getControl(focusid).setLabel(self.ruleList[self.selectedRuleIndex].onAction(act, (focusid - 160) + (self.optionRowOffset * 2)))

if action == ACTION_PREVIOUS_MENU:
if action in ACTION_PREVIOUS_MENU:
if self.selectedRuleIndex > -1:
xbmc.executebuiltin("SetProperty(itempress,100)")
xbmc.executebuiltin("Control.SetFocus(120)")
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/Channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def __init__(self):
self.isSetup = False


def log(self, msg):
log('Channel: ' + msg)
def log(self, msg, level = xbmc.LOGDEBUG):
log('Channel: ' + msg, level)


def setPlaylist(self, filename):
Expand Down
49 changes: 31 additions & 18 deletions resources/lib/ChannelList.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def readConfig(self):
self.startMode = int(REAL_SETTINGS.getSetting("StartMode"))
self.log('Start Mode is ' + str(self.startMode))
self.backgroundUpdating = int(REAL_SETTINGS.getSetting("ThreadMode"))
self.incIceLibrary = REAL_SETTINGS.getSetting('IncludeIceLib') == "true"
self.log("IceLibrary is " + str(self.incIceLibrary))
self.showSeasonEpisode = REAL_SETTINGS.getSetting("ShowSeEp") == "true"
self.findMaxChannels()

if self.forceReset:
Expand Down Expand Up @@ -276,11 +279,6 @@ def setupChannel(self, channel, background = False, makenewlist = False, append
except:
pass

try:
needsreset = ADDON_SETTINGS.getSetting('Channel_' + str(channel) + '_changed') == 'True'
except:
pass

while len(self.channels) < channel:
self.channels.append(Channel())

Expand All @@ -293,6 +291,11 @@ def setupChannel(self, channel, background = False, makenewlist = False, append
self.runActions(RULES_ACTION_START, channel, self.channels[channel - 1])
GlobalFileLock.lockFile(CHANNELS_LOC + 'channel_' + str(channel) + '.m3u', True)

try:
needsreset = ADDON_SETTINGS.getSetting('Channel_' + str(channel) + '_changed') == 'True'
except:
pass

# If possible, use an existing playlist
# Don't do this if we're appending an existing channel
# Don't load if we need to reset anyway
Expand Down Expand Up @@ -1129,9 +1132,16 @@ def buildFileList(self, dir_name, channel):
except:
dur = 0

# Remove any file types that we don't want (ex. IceLibrary)
if self.incIceLibrary == False:
if match.group(1).replace("\\\\", "\\")[-4:].lower() == 'strm':
dur = 0

try:
if dur > 0:
filecount += 1
seasonval = -1
epval = -1

if self.background == False:
if filecount == 1:
Expand All @@ -1151,7 +1161,21 @@ def buildFileList(self, dir_name, channel):

# This is a TV show
if showtitle != None and len(showtitle.group(1)) > 0:
tmpstr += showtitle.group(1) + "//" + title.group(1) + "//" + theplot
season = re.search('"season" *: *(.*?),', f)
episode = re.search('"episode" *: *(.*?),', f)
swtitle = title.group(1)

try:
seasonval = int(season.group(1))
epval = int(episode.group(1))

if self.showSeasonEpisode:
swtitle = swtitle + '(S' + ('0' if seasonval < 10 else '') + str(seasonval) + ' E' + ('0' if epval < 10 else '') + str(epval) + ')'
except:
seasonval = -1
epval = -1

tmpstr += showtitle.group(1) + "//" + swtitle + "//" + theplot
istvshow = True
else:
tmpstr += title.group(1) + "//"
Expand All @@ -1174,18 +1198,7 @@ def buildFileList(self, dir_name, channel):
tmpstr = tmpstr + '\n' + match.group(1).replace("\\\\", "\\")

if self.channels[channel - 1].mode & MODE_ORDERAIRDATE > 0:
if istvshow:
season = re.search('"season" *: *(.*?),', f)
episode = re.search('"episode" *: *(.*?),', f)

try:
seasonval = int(season.group(1))
epval = int(episode.group(1))
seasoneplist.append([seasonval, epval, tmpstr])
except:
seasoneplist.append([-1, -1, tmpstr])
else:
seasonplist.append([-1, -1, tmpstr])
seasoneplist.append([seasonval, epval, tmpstr])
else:
fileList.append(tmpstr)
except:
Expand Down
54 changes: 38 additions & 16 deletions resources/lib/ChannelListThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,23 @@ def run(self):

self.chanlist.channels[i].setAccessTime(self.myOverlay.channels[i].lastAccessTime)

if self.chanlist.setupChannel(i + 1, True, True, False) == True:
while self.paused:
if self.myOverlay.isExiting:
self.log("IsExiting")
return

time.sleep(1)

self.myOverlay.channels[i] = self.chanlist.channels[i]

if self.myOverlay.channels[i].isValid == True:
xbmc.executebuiltin("Notification(PseudoTV, Channel " + str(i + 1) + " Added, 4000)")
try:
if self.chanlist.setupChannel(i + 1, True, True, False) == True:
while self.paused:
if self.myOverlay.isExiting:
self.log("IsExiting")
return

time.sleep(1)

self.myOverlay.channels[i] = self.chanlist.channels[i]

if self.myOverlay.channels[i].isValid == True:
xbmc.executebuiltin("Notification(PseudoTV, Channel " + str(i + 1) + " Added, 4000)")
except:
self.log("Unknown Channel Creation Exception", xbmc.LOGERROR)
self.log(traceback.format_exc(), xbmc.LOGERROR)
return

REAL_SETTINGS.setSetting('ForceChannelReset', 'false')
self.chanlist.sleepTime = 0.3
Expand Down Expand Up @@ -128,18 +133,35 @@ def run(self):
self.chanlist.channels[i].isPaused = self.myOverlay.channels[i].isPaused
self.chanlist.channels[i].mode = self.myOverlay.channels[i].mode
# Only allow appending valid channels, don't allow erasing them
self.chanlist.setupChannel(i + 1, True, False, True)

try:
self.chanlist.setupChannel(i + 1, True, False, True)
except:
self.log("Unknown Channel Appending Exception", xbmc.LOGERROR)
self.log(traceback.format_exc(), xbmc.LOGERROR)
return

self.chanlist.channels[i].playlistPosition = self.myOverlay.channels[i].playlistPosition
self.chanlist.channels[i].showTimeOffset = self.myOverlay.channels[i].showTimeOffset
self.chanlist.channels[i].lastAccessTime = self.myOverlay.channels[i].lastAccessTime
self.chanlist.channels[i].totalTimePlayed = self.myOverlay.channels[i].totalTimePlayed
self.chanlist.channels[i].isPaused = self.myOverlay.channels[i].isPaused
self.chanlist.channels[i].mode = self.myOverlay.channels[i].mode
else:
self.chanlist.setupChannel(i + 1, True, True, False)
try:
self.chanlist.setupChannel(i + 1, True, True, False)
except:
self.log("Unknown Channel Modification Exception", xbmc.LOGERROR)
self.log(traceback.format_exc(), xbmc.LOGERROR)
return
else:
# We're not master, so no modifications...just try and load the channel
self.chanlist.setupChannel(i + 1, True, False, False)
try:
# We're not master, so no modifications...just try and load the channel
self.chanlist.setupChannel(i + 1, True, False, False)
except:
self.log("Unknown Channel Loading Exception", xbmc.LOGERROR)
self.log(traceback.format_exc(), xbmc.LOGERROR)
return

self.myOverlay.channels[i] = self.chanlist.channels[i]

Expand Down
Loading

0 comments on commit 6696b49

Please sign in to comment.