Browse files

support for serving BIF's, from JT

  • Loading branch information...
1 parent 94f00aa commit 84742eafd2ebe9b439afc9fa1d014bd2091ae8de @netguy204 committed May 13, 2011
Showing with 35 additions and 10 deletions.
  1. +13 −1 client/source/datamodel.brs
  2. +10 −8 server/common.py
  3. +12 −1 server/mymedia.py
View
14 client/source/datamodel.brs
@@ -204,6 +204,8 @@ Function newMediaFromXML(rss As Object, xml As Object) As Object
GetDescription:itemGetDescription,
GetStreamFormat:itemGetStreamFormat,
GetContentType:itemGetContentType,
+ GetSubtitleUrl:itemGetSubtitleUrl,
+ GetBifUrl:itemGetBifUrl,
GetType:itemGetType,
GetLength:itemGetLength,
GetAlbum:itemGetAlbum,
@@ -243,6 +245,14 @@ Function itemGetContentType()
return m.xml.ContentType.GetText()
End Function
+Function itemGetSubtitleUrl()
+ return m.xml.SubtitleUrl.GetText()
+End Function
+
+Function itemGetBifUrl()
+ return m.xml.BifUrl.GetText()
+End Function
+
Function itemGetLength()
l = m.xml.playtime.GetText()
return l.toInt()
@@ -265,7 +275,9 @@ Function itemGetPlayable()
'print "type: "; m.GetType()
sf = m.GetStreamFormat()
ct = m.GetContentType()
- return { Url: m.GetMedia(), ContentType: ct, Title: m.GetTitle(), StreamFormat: sf,
+ stu = m.GetSubtitleUrl()
+ bu = m.GetBifUrl()
+ return { Url: m.GetMedia(), ContentType: ct, Title: m.GetTitle(), StreamFormat: sf, SubtitleUrl:stu, SDBifUrl:bu, HDBifUrl:bu,
Length: m.GetLength(), Artist: m.GetArtist(), Album: m.GetAlbum(), ReleaseDate: m.GetDate()}
End Function
View
18 server/common.py
@@ -39,7 +39,7 @@ def ensure(varname, default):
ensure("collapse_collections", "False")
ensure("max_folders_before_split", "10")
ensure("theme", "default")
-
+
# make a reasonable guess at where the user keeps their music
default_music_path = "Music"
default_video_path = "Video"
@@ -97,11 +97,11 @@ def relpath26(path, start=os.curdir):
# cross platform python2.5 terminator found on stackoverflow
def terminate(process):
"""
- Kills a process, useful on 2.5 where subprocess.Popens don't have a
+ Kills a process, useful on 2.5 where subprocess.Popens don't have a
terminate method.
- Used here because we're stuck on 2.5 and don't have Popen.terminate
+ Used here because we're stuck on 2.5 and don't have Popen.terminate
goodness.
"""
@@ -117,7 +117,7 @@ def terminate_nix(process):
terminate_default = terminate_nix
handlers = {
- "win32": terminate_win,
+ "win32": terminate_win,
"linux2": terminate_nix
}
@@ -206,7 +206,7 @@ def ext2mime(ext2):
ext = ext2[-4:].lower()
if ext == "m3u8":
return "application/vnd.apple.mpegurl"
-
+
ext = ext2[-3:].lower()
if ext == "mp3":
return "audio/mpeg"
@@ -226,10 +226,12 @@ def ext2mime(ext2):
return "video/x-ms-wmv"
elif ext == "srt":
return "text/plain"
-
+ elif ext == "bif":
+ return "application/binary"
+
ext = ext2[-2:].lower()
if ext == "ts":
- return "video/MP2T"
+ return "video/MP2T"
else:
return None
@@ -356,7 +358,7 @@ def getimg(file):
except Exception, e:
logging.debug("Error while looking for images in %s: %s" % (file, str(e)))
return None, None
-
+
# from the roku component reference
THB_SD_DIM = (223,200)
THB_HD_DIM = (300,300)
View
13 server/mymedia.py
@@ -67,7 +67,7 @@ def set_variables(self, kwargs):
class RSSImageItem(PublishMixin, RSSItem):
"extending rss items to support our extended tags"
def __init__(self, **kwargs):
- self.TAGS = ('image', 'filetype', 'tracknum', 'ContentType', 'StreamFormat', 'playtime', 'album', 'bitrate', 'release_date', 'SubtitleUrl')
+ self.TAGS = ('image', 'filetype', 'tracknum', 'ContentType', 'StreamFormat', 'playtime', 'album', 'bitrate', 'release_date', 'SubtitleUrl', 'BifUrl')
self.set_variables(kwargs)
RSSItem.__init__(self, **kwargs)
@@ -159,6 +159,15 @@ def with_srt(fname, linker, addl):
addl['SubtitleUrl'] = linker(srtname)
return addl
+def with_bif(fname, linker, addl):
+ "update the addl with a bif tag if that file is available"
+
+ basepath = os.path.splitext(fname)[0]
+ bifname = basepath + ".bif"
+ if os.path.exists(bifname):
+ addl['BifUrl'] = linker(bifname)
+ return addl
+
def file2item(key, fname, base_dir, config, image=None):
if not os.path.exists(fname):
logging.warning("WARNING: Tried to create feed item for `%s' which does not exist. This shouldn't happen" % fname)
@@ -229,6 +238,7 @@ def make_addl_link(fname):
basename = os.path.split(fname)[1]
title = os.path.splitext(basename)[0]
with_srt(fname, make_addl_link, addl)
+ with_bif(fname, make_addl_link, addl)
description = "Video"
filetype = "mp4"
@@ -241,6 +251,7 @@ def make_addl_link(fname):
basename = os.path.split(fname)[1]
title = os.path.splitext(basename)[0]
with_srt(fname, make_addl_link, addl)
+ with_bif(fname, make_addl_link, addl)
description = "Video"
filetype = "wmv"

0 comments on commit 84742ea

Please sign in to comment.