Skip to content

Commit

Permalink
Adding transcode selection preference for HDTC-2US. (#3)
Browse files Browse the repository at this point in the history
* Adding transcode selection preference for HDTC-2US.

* Adding transcode selection preference for HDTC-2US.

* Adding transcode selection preference for HDTC-2US.
  • Loading branch information
fallen751 authored and jumpmanjay committed Sep 20, 2016
1 parent acf36ca commit 458d781
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 63 deletions.
114 changes: 57 additions & 57 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def Start():
VideoClipObject.thumb = R(ICON)

@handler(PREFIX, TITLE, thumb=ICON)

def MainMenu():
global pyhdhr
pyhdhr = PyHDHR()

oc = ObjectContainer()
oc.add(DirectoryObject(key=Callback(ShowLiveTV, title=L('LiveTV')), title=L('LiveTV'), thumb=R(ICON_LIVETV)))
oc.add(DirectoryObject(key=Callback(ShowMainRecordingsMenu, title=L('Recordings')), title=L('Recordings'), thumb=R(ICON_RECORDINGS)))
Expand All @@ -63,7 +63,7 @@ def ShowLiveTV(title):
oc.add(DirectoryObject(key=Callback(ShowFavoriteChannels, title=L('FavoriteChannels')), title=L('FavoriteChannels'), thumb=R(ICON_FAVORITES)))
oc.add(DirectoryObject(key=Callback(ShowAllChannels, title=L('AllChannels')), title=L('AllChannels'), thumb=R(ICON_ALLCHANNELS)))
oc.add(DirectoryObject(key=Callback(ShowHDChannels, title=L('HDChannels')), title=L('HDChannels'), thumb=R(ICON_HDCHANNELS)))
oc.add(DirectoryObject(key=Callback(ShowSDChannels, title=L('SDChannels')), title=L('SDChannels'), thumb=R(ICON_SDCHANNELS)))
oc.add(DirectoryObject(key=Callback(ShowSDChannels, title=L('SDChannels')), title=L('SDChannels'), thumb=R(ICON_SDCHANNELS)))
oc.add(DirectoryObject(key=Callback(ShowWhatsOn, title=L('WhatsOn')), title=L('WhatsOn'), thumb=R(ICON_LIVETV)))
oc.add(InputDirectoryObject(key=Callback(SearchLiveTV), title=L('SearchLiveTV'), thumb=R(ICON_SEARCH)))
return oc
Expand All @@ -72,10 +72,10 @@ def ShowLiveTV(title):
def ShowFavoriteChannels(title):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

cl = pyhdhr.getChannelList()
for line in cl:
chan = pyhdhr.getChannelInfo(str(line))
Expand All @@ -97,10 +97,10 @@ def ShowFavoriteChannels(title):
def ShowAllChannels(title):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

cl = pyhdhr.getChannelList()
for line in cl:
chan = pyhdhr.getChannelInfo(str(line))
Expand All @@ -121,10 +121,10 @@ def ShowAllChannels(title):
def ShowHDChannels(title):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

cl = pyhdhr.getChannelList()
for line in cl:
chan = pyhdhr.getChannelInfo(str(line))
Expand All @@ -141,15 +141,15 @@ def ShowHDChannels(title):
chantitle = chantitle+" )"
oc.add(DirectoryObject(key=Callback(ShowTunedTVStaged,title=str(chantitle),guideno=str(line)), title=str(chantitle),thumb=(chan.getImageURL() if chan.getImageURL() else R(ICON_BROKEN))))
return oc

@route(PREFIX + '/showsdchannels')
def ShowSDChannels(title):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

cl = pyhdhr.getChannelList()
for line in cl:
chan = pyhdhr.getChannelInfo(str(line))
Expand All @@ -171,10 +171,10 @@ def ShowSDChannels(title):
def ShowWhatsOn(title):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

progs = pyhdhr.getWhatsOn()
for guideno in progs:
eptitle = ""
Expand All @@ -185,7 +185,7 @@ def ShowWhatsOn(title):
oc.add(DirectoryObject(key=Callback(ShowTunedTVStaged, title=str(eptitle),guideno=guideno), title=str(eptitle), thumb=(progs[guideno].getImageURL() if progs[guideno].getImageURL() else R(ICON_UNKNOWN))))
oc.objects.sort(key = lambda obj: obj.title)
return oc

@route(PREFIX + '/showtunedtvstaged')
def ShowTunedTVStaged(title,guideno):
oc = ObjectContainer(title2=title)
Expand All @@ -204,28 +204,28 @@ def ShowMainRecordingsMenu(title):
def ShowAllRecordings(title):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

rp = pyhdhr.getFilteredRecordedPrograms(SortType.asc,GroupType.All,None)
if rp:
for r in rp:
obj = ShowRecording(recprogkey=r.getProgramID())
if obj:
oc.add(obj)
return oc

@route(PREFIX + '/showrecordingsbyseriesmenu')
def ShowRecordingsBySeriesMenu(title):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

series = pyhdhr.getRecordedSeries()

if series:
for titlekey in sorted(series):
oc.add(TVShowObject(key=Callback(ShowRecordingsBySeries, title=str(titlekey), seriesid=series[titlekey].getSeriesID()), title=str(titlekey), thumb=(series[titlekey].getImageURL() if series[titlekey].getImageURL() else R(ICON_UNKNOWN)),episode_count=(series[titlekey].getEpisodeCount()-1),rating_key=series[titlekey].getSeriesID()))
Expand All @@ -235,7 +235,7 @@ def ShowRecordingsBySeriesMenu(title):
def ShowRecordingsBySeries(title,seriesid):
global pyhdhr
oc = ObjectContainer(title2=title)

if not pyhdhr:
pyhdhr = PyHDHR()

Expand All @@ -251,7 +251,7 @@ def ShowRecordingsBySeries(title,seriesid):
def SearchAll(query):
global pyhdhr
oc = ObjectContainer(title2="search all...")

if not pyhdhr:
pyhdhr = PyHDHR()

Expand All @@ -273,7 +273,7 @@ def SearchAll(query):
def SearchLiveTV(query):
global pyhdhr
oc = ObjectContainer(title2="search live tv...")

if not pyhdhr:
pyhdhr = PyHDHR()

Expand All @@ -288,48 +288,48 @@ def SearchLiveTV(query):
def SearchRecorded(query):
global pyhdhr
oc = ObjectContainer(title2='Search Results for \''+str(query)+'\'')

if not pyhdhr:
pyhdhr = PyHDHR()

progs = pyhdhr.searchRecorded(query)

if len(progs) > 0:
for recprogkey in progs:
oc.add(ShowRecording(recprogkey=recprogkey))
oc.add(ShowRecording(recprogkey=recprogkey))
return oc

@route(PREFIX + '/showtunedtv')
def ShowTunedTV(guideno,include_container=False):
global pyhdhr
if not pyhdhr:
pyhdhr = PyHDHR()

chaninfo = pyhdhr.getLiveTVChannelInfo(guideno)
if chaninfo:
liveurl = chaninfo.getURL()
cont = 'mpegts'
vcodec = 'mpeg2video'
acodec = 'ac3'

t = chaninfo.getTuner()
Log.Debug("Tuner: " + t.getModelNumber())

if t.getModelNumber() == "HDTC-2US":
if Prefs['UseDefaultTranscoding'] == True:
if Prefs['TranscodeType'] == "SD Configured":
transcodeoption = t.getTranscodeOption()
if not transcodeoption:
liveurl = liveurl + "?transcode=none"
transcodeoption = "none"
Log.Debug("Could not get tuner transcode option, using none")
else:
Log.Debug("Tuner transcode option: " + transcodeoption)
if transcodeoption != "none":
cont = 'mp4'
vcodec = 'h264'
acodec = 'ac3'
liveurl = liveurl + "?transcode="+transcodeoption
else:
liveurl = liveurl + "?transcode=none"
transcodeoption = Prefs['TranscodeType']

Log.Debug("Tuner transcode option: " + transcodeoption)
if transcodeoption != "none":
cont = 'mp4'
vcodec = 'h264'
acodec = 'ac3'
liveurl = liveurl + "?transcode="+transcodeoption
else:
if chaninfo.getVideoCodec() == "MPEG2":
cont = 'mpegts'
Expand All @@ -348,12 +348,12 @@ def ShowTunedTV(guideno,include_container=False):
else:
msg = "Unknown audio codec: " + chaninfo.getAudioCodec()+". Using default"
Log.Critical(msg)

p_title = ""
p_stitle = ""
p_synopsis = ""
p_imageurl = ""

proginfo = pyhdhr.getWhatsOn(guideno)
if not proginfo:
p_title=chaninfo.getGuideNumber()
Expand All @@ -365,11 +365,11 @@ def ShowTunedTV(guideno,include_container=False):
p_stitle=proginfo.getEpisodeTitle()
p_synopsis=proginfo.getSynopsis()
p_imageurl=proginfo.getImageURL()

brate = None
aratio = None
vpix = None

if chaninfo.getHD() == 1:
aratio = "1.78"
vpix = 1080
Expand All @@ -384,9 +384,9 @@ def ShowTunedTV(guideno,include_container=False):
brate = 4000
else:
brate = 1500

Log.Debug("Using the following MediaObject profile:\ncontainer: "+cont+",\nvideo codec: "+vcodec+",\naudio codec: "+acodec+",\nbitrate: "+str(brate)+",\naspect_ratio: "+aratio+",\nvideo_resolution: "+str(vpix))

obj = EpisodeObject(
key=Callback(ShowTunedTV,guideno=guideno,include_container=True),
url=liveurl,
Expand All @@ -395,7 +395,7 @@ def ShowTunedTV(guideno,include_container=False):
summary=p_synopsis,
duration=14400000,
thumb=(p_imageurl if p_imageurl else R(ICON_UNKNOWN)),
items = [
items = [
MediaObject(
parts = [
PartObject(
Expand All @@ -410,9 +410,9 @@ def ShowTunedTV(guideno,include_container=False):
aspect_ratio=aratio,
video_resolution=vpix
)
]
]
)

if include_container:
return ObjectContainer(objects=[obj])
else:
Expand All @@ -427,29 +427,29 @@ def ShowRecording(recprogkey,include_container=False):
global pyhdhr
if not pyhdhr:
pyhdhr = PyHDHR()

prog = pyhdhr.getRecordedProgram(recprogkey)
if prog:

cont = 'mpegts'
vcodec = 'mpeg2video'
acodec = 'ac3'
brate = 13000
aratio = "1.78"
vpix = 1080

chaninfo = pyhdhr.getChannelInfo(prog.getChannelNumber())
if chaninfo:
t = chaninfo.getTuner()
Log.Debug("Tuner: " + t.getModelNumber())

if t.getModelNumber() == "HDTC-2US":
transcodeoption = t.getTranscodeOption()
if not transcodeoption:
Log.Debug("Could not get tuner transcode option, using none")
vcodec = 'mpeg2video'
acodec = 'ac3'
else:
else:
Log.Debug("Tuner transcode option: " + transcodeoption)
if transcodeoption == "none":
cont = 'mpegts'
Expand Down Expand Up @@ -477,7 +477,7 @@ def ShowRecording(recprogkey,include_container=False):
else:
msg = "Unknown audio codec: " + chaninfo.getAudioCodec()+". Using default"
Log.Critical(msg)

if chaninfo.getHD() == 1:
aratio = "1.78"
vpix = 1080
Expand All @@ -497,7 +497,7 @@ def ShowRecording(recprogkey,include_container=False):
Log.Critical(msg)

Log.Debug("Using the following MediaObject profile:\ncontainer: "+cont+",\nvideo codec: "+vcodec+",\naudio codec: "+acodec+",\nbitrate: "+str(brate)+",\naspect_ratio: "+aratio+",\nvideo_resolution: "+str(vpix))

obj = EpisodeObject(
key=Callback(ShowRecording,recprogkey=recprogkey,include_container=True),
url=prog.getPlayURL(),
Expand All @@ -506,7 +506,7 @@ def ShowRecording(recprogkey,include_container=False):
summary=prog.getSynopsis(),
duration=((prog.getRecordEndTime() - prog.getRecordStartTime()) * 1000),
thumb=(prog.getImageURL() if prog.getImageURL() else R(ICON_UNKNOWN)),
items = [
items = [
MediaObject(
parts = [
PartObject(
Expand All @@ -521,9 +521,9 @@ def ShowRecording(recprogkey,include_container=False):
aspect_ratio=aratio,
video_resolution=vpix
)
]
]
)

if include_container:
return ObjectContainer(objects=[obj])
else:
Expand Down
13 changes: 7 additions & 6 deletions Contents/DefaultPrefs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[
{
"id": "UseDefaultTranscoding",
"label": "Use configured default transcoding profile on Extend tuners for live TV",
"type": "bool",
"default": "false"
},
{
"id": "TranscodeType",
"type": "enum",
"label": "Tuner transcode (HDTC-2US only)",
"values": ["SD Configured","none","heavy","mobile","internet540","internet480","internet360","internet240"],
"default": "SD Configured"
},
{
"id": "EnableDebug",
"label": "Enable debugging menu option",
Expand Down

0 comments on commit 458d781

Please sign in to comment.