Play

The play function will allow you to do some post processing if an item should be played. The stream_id variable is poassed from the episode, list or search function an can be manipulated. For example scraping the streaming path of a specific page. You can also pass the stream_id directly to the player if you want, make sure you setup the function in the corresponding way. There is also a possibility to add a subtitle if available.

 

  1. def Play(self, stream_name, stream_id, subtitle):
  2.         """Start your code here"""
  3.        
  4.         """End your code here"""
  5.         return play

Receiving variables:

Variable Type Description
stream_name string Contains the name of the stream
stream_id string Contains the id of the stream
subtitle Boolean[ [True,False] Returns the user setting for subtitles

 

To return the path information in the correct way the frameworks expects the returned information in a specific output. There can only be returned one streaming item at once, no lists. An example of such an configuration is:

  1. play = ba.CreatePlay()
  2. play.SetPath(streampath)
  3.  
  4. #Optional
  5. if subtitle:
  6.    play.SetSubtitle(subtitlepath)
  7.    play.SetSubtitle_type(string)
  8.  
  9. return play

 

Explanation of the code:

 

  1. play = ba.CreatePlay()

An instance is created for the stream item

 

  1. play.SetPath(streampath)

The SetPath variable will set the path to be played by the boxee player.

 

  1. return play

Returning the play object to the framework

 

Optional:

  1. if subtitle:

Checks if the user has enabled subtitles

 

  1. play.SetSubtitle(subtitlepath)

Add a subtitle path to the stream, make sure boxee supports it.

 

  1. play.SetSubtitle_type(string)

Only applicable on sami subtitles. Boxee has problems with them and when setting SetSubtitle_type to ‘sami’ the framework will automatically converts and passes the subtitle to a temporary srt subtitle file.

 

Static Example Flash:

  1. def Play(self, stream_name, stream_id, subtitle):
  2.  
  3.         play = ba.CreatePlay()
  4.         play.SetPath(stream_id)
  5.         play.SetDomain(‘youtube.com’)
  6.         play.SetJSactions()
  7.  
  8.         return play

 

Scrape Example:

  1. def Play(self, stream_name, stream_id, subtitle):
  2.         data = ba.FetchUrl(stream_id)
  3.         url_play = re.compile(‘<a class="wmv-player-holder" href="(.*?)"></a>’, re.DOTALL + re.IGNORECASE).search(data).group(1)
  4.  
  5.         play = ba.CreatePlay()
  6.         play.SetPath(url_play)
  7.  
  8.         return play

  • *

    You may use these HTML tags: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong>

  • Comment Feed for this Post
Go to Top