Skip to content

Commit

Permalink
version 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
salphonso committed Dec 3, 2015
1 parent f6ab1fa commit f42df8e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
43 changes: 29 additions & 14 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
SERVERWMC_IP = Prefs['serverwmc_ip']
SERVERWMC_PORT = Prefs['serverwmc_port']
SERVERWMC_ADDR = (SERVERWMC_IP, int(SERVERWMC_PORT))
VERSION = '0.9.0'
VERSION = '0.10.0'
MACHINENAME = socket.gethostname()
IDSTREAMINT = 0
GETSTREAMINFO = 'IncludeStreamInfo'
Expand All @@ -40,15 +40,16 @@
STREAMID = 0
DURATION = 14400000



####################################################################################################
def Start():

# Get time zone hour difference in seconds
Plugin.AddViewGroup("Details", viewMode="InfoList", mediaType="items")
Plugin.AddViewGroup("List", viewMode="List", mediaType="items")
u.getTimeDif()
ObjectContainer.art = R(ART)
ObjectContainer.title1 = NAME
ObjectContainer.view_group = 'Details'
socketClient('GetServerVersion', '')

####################################################################################################
Expand All @@ -65,28 +66,36 @@ def MainMenu():
oc.add(PrefsObject(title='Settings', thumb=R('icon-settings.png')))

# Channels
oc.add(DirectoryObject(key = Callback(SubMenu, menu='LiveTV'), title='LiveTV', thumb=R(CHANNEL_ICON)))
oc.add(DirectoryObject(key = Callback(SubMenu, menu='Guide'), title='Guide', thumb=R(CHANNEL_ICON)))
oc.add(DirectoryObject(key = Callback(SubMenu, title='Channels'), title='Channels', thumb=R(CHANNEL_ICON)))
oc.add(DirectoryObject(key = Callback(SubMenu, title='Guide'), title='Guide', thumb=R(CHANNEL_ICON)))
oc.add(DirectoryObject(key = Callback(GetTimers), title='Scheduled Recordings', thumb=R(TIMER_ICON)))
oc.add(DirectoryObject(key = Callback(GetRecordings), title='Recorded TV', thumb=R(RECORDEDTV_ICON)))

return oc

####################################################################################################
@route(PREFIX +'/SubMenu/{menu}')
def SubMenu(menu):
@route(PREFIX +'/SubMenu/{title}', offset=int)
def SubMenu(title, offset = 0):

oc = ObjectContainer(title2=title, no_cache=True)

oc = ObjectContainer(title2=menu, no_cache=True)
counter = 0
itemsPerPage = int(Prefs['ItemsPerPage'])

# Connect and Get Channel List
resultsArray = socketClient('GetChannels', '')

if DEBUG == 'Verbose':
Log.Debug('----------SubMenu Function : ' + menu + '----------')
Log.Debug('----------SubMenu Function : ' + title + '----------')
Log.Debug(resultsArray)

# Loop through resultsArray to build Channel objects
for result in resultsArray:
counter = counter + 1

if counter <= offset:
continue

channelArray = result.split('|')
channelID = channelArray[0]
try:
Expand All @@ -101,7 +110,7 @@ def SubMenu(menu):
channelTitle = channelName + '(' + channelNumber + ')'
channelURL = channelArray[9]
Thumb = channelImageFile
if menu == 'Guide':
if title == 'Guide':
summaryData = getListingInfo(chID=channelID, progItem='programName', infoType='nowPlaying')
summaryData = summaryData + ' : ' + getListingInfo(chID=channelID, progItem='programOverview', infoType='nowPlaying')
Summary='Now Playing : ' + summaryData
Expand All @@ -113,19 +122,24 @@ def SubMenu(menu):
Log.Debug(channelTitle + ', ' + channelURL + ', ' + channelImageFile + ', '
+ channelNumber + ', ' + channelName)

if menu=='Guide':
if title=='Guide':
oc.add(DirectoryObject(key=Callback(
CreateChannel, url=channelURL, chID=channelID, title=channelTitle, thumb=Thumb),
title=channelTitle, summary=Summary, thumb=Thumb))

if menu=='LiveTV':
if title=='Channels':
oc.add(CreateVCO(
url=channelURL,
title=channelTitle,
summary=Summary,
duration=DURATION,
icon=Thumb)
)

if len(oc) >= itemsPerPage:
oc.add(NextPageObject(key = Callback(SubMenu, title = title, offset = counter), title = "Next..."))

return oc

return oc

Expand All @@ -139,7 +153,7 @@ def CreateChannel(url, chID, title, thumb):

# Get Start and end datetime and convert to seconds
startDt = u.getTimeS(datetime.datetime.utcnow())
endDt = int(startDt + (timedelta(days=EPGDAYS)).total_seconds())
endDt = int(startDt + (timedelta(days=int(Prefs['serverwmc_epg_days']))).total_seconds())

# build request string
sendCommand = 'GetEntries|{0}|{1}|{2}'.format(chID, startDt, endDt)
Expand Down Expand Up @@ -260,7 +274,7 @@ def getListingInfo(chID, progItem, infoType='Upcoming', startDt='', endDt=''):
# Get Start and end datetime and convert to seconds
if infoType != 'singleItem':
startDt = u.getTimeS(datetime.datetime.utcnow())
endDt = int(startDt + (timedelta(days=EPGDAYS)).total_seconds())
endDt = int(startDt + (timedelta(days=int(Prefs['serverwmc_epg_days']))).total_seconds())

# build request string
sendCommand = 'GetEntries|{0}|{1}|{2}'.format(chID, startDt, endDt)
Expand Down Expand Up @@ -821,3 +835,4 @@ class recordingState_wmc(enumerate):
recording = 3
recorded = 4
deleted = 5

6 changes: 6 additions & 0 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"values": ["1","2","3","4","5","6","7"],
"default": "1"
},
{
"id": "ItemsPerPage",
"type": "text",
"label": "Items Per Page",
"default": "25"
},
{
"id": "serverwmc_quality",
"type": "enum",
Expand Down

0 comments on commit f42df8e

Please sign in to comment.