List

The list function will allow you the specify a static list of streams.

You have to understand there are 2 ways of searching in the framework. 1 a dynamic search 2 a static list. A dynamic search ‘plugs-into’ a searchengine of a other site and fetches the results. A static list just scrapes a simple static stream lists from a website or array. See also the chapter search.

To enable the list function use the starting code below and make sure you add ‘list’ to the self.type variable in the general module configuration. See also the init section.

 

  1. def List(self):
  2.     """Start your code here"""
  3.        
  4.     """End your code here"""
  5.     return streamlist

Receiving variables:

Variable Type Description
- - -

 

A static list can be specified as a list of stream urls directly put into the module script or it can be scraped from a website. The list script is called once every 3 days when activated to update the variables and store the data into the framework database.

 

To return the streamlist in the correct way the frameworks expects the returned information in a specific output. A single stream should be put into an object and the array of streams should be put in a list. An example of such an configuration is:

  1. streamlist = list()
  2. for item in VarA:
  3.     stream = ba.CreateStream()
  4.     stream.SetName(item[0])
  5.     stream.SetId(item[1])
  6.     streamlist.append(stream)
  7. return streamlist

 

Explanation of the code:

  1. streamlist = list()

The streamlist is set as list variabe

 

  1. for item in VarA:

A loop is started iterating the array ‘VarA’

 

  1. stream = ba.CreateStream()

An instance is created for the stream item

 

  1. stream.SetName(item[0])

The SetName variable will give the stream its visible name in the app. Passing the variable item[0] to it in this case.

 

  1. stream.SetId(item[1])

The SetId variable will give the stream its id parameter, this will be passed to the episode function or directly to the boxee player if there are no episodes. It can be a path or a id to be processed later. The content should be set as string. Passing the variable item[1] to it in this case.

 

  1. streamlist.append(stream)

Appending the instance to the end of the streamlist list.

 

  1. return streamlist

returning the streamlist list to the framework

 

Scraping Example:

  1. def List(self):
  2.         url = "www.example.com/a-z"
  3.         data = ba.FetchUrl(url)
  4.         soup = BeautifulSoup(data, convertEntities="xml", smartQuotesTo="xml")
  5.  
  6.         div_main  = soup.findAll( ‘div’, {‘class’ : ‘mo-a alphabetical’})[0]
  7.         div_show  = div_main.findAll( ‘div’, {‘class’ : ‘wrapper’})[0]
  8.  
  9.         streamlist = list()
  10.         for info in div_show.findAll(‘a’):
  11.             stream = ba.CreateStream()
  12.             name = info.contents[0]
  13.             id = self.url_base + info[‘href’]
  14.             if not name in self.exclude:
  15.                 stream.SetName(name)
  16.                 stream.SetId(id)
  17.                 streamlist.append(stream)
  18.  
  19.         return streamlist

 

Direct play Example:

  1. def List(self):
  2.         channels = [
  3.             ["101 TV", "%s/npo/101tv-%s"],
  4.             ["Best 24", "%s/npo/best24-%s"],
  5.             ["Consumenten 24", "%s/npo/consumenten24-%s"],
  6.             ["Cultura 24", "%s/npo/cultura24-%s"],
  7.             ["Familie 24 / Z@ppelin", "%s/npo/familie24-%s"],
  8.             ["Geschiedenis 24", "%s/npo/geschiedenis24-%s"],
  9.             ["Holland Doc 24", "%s/npo/hollanddoc24-%s"],
  10.             ["Humor TV 24", "%s/npo/humortv24-%s"],
  11.             ["Journaal 24", "%s/nos/journaal24-%s"],
  12.             ["Politiek 24", "%s/nos/politiek24-%s"],
  13.             ["Spirit 24", "%s/npo/spirit24-%s"],
  14.             ["Sterren 24", "%s/npo/sterren24-%s"]
  15.         ]
  16.                 streamlist = list()
  17.         for item in channels:
  18.             stream = ba.CreateStream()
  19.             stream.SetName(item[0])
  20.             stream.SetId(item[1])
  21.             streamlist.append(stream)
  22.  
  23.         return streamlist

  • *

    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