Make CapCollection understandable and useable by humans
* Make the declaration of fct and it in the constructor Collection, instead of adding them from the outside * Add a function to flatten a list containing collection (solves the radioob search crash) * Better display of collections in the "ls" command (and display both id and title) * The "cd" command goes to the root of the path (like the UNIX cd) * Move the Video object of canalplus in a correct path * Make Collection iterable * Add comments to CapCollection * Cache the result of fct in a Collection; it is only called once * CollectionNotFound errors can be more explicit by providing a path * Require utf-8 in collection paths * Code cleanups
This commit is contained in:
parent
10215d1e4c
commit
682e14c86a
14 changed files with 125 additions and 63 deletions
|
|
@ -159,19 +159,20 @@ class RadioFranceBackend(BaseBackend, ICapRadio, ICapCollection):
|
|||
|
||||
def iter_resources(self, split_path):
|
||||
if len(split_path) == 1 and split_path[0] == 'francebleu':
|
||||
for id in sorted(self._RADIOS.iterkeys()):
|
||||
if id.startswith('fb'):
|
||||
yield self.get_radio(id)
|
||||
for _id in sorted(self._RADIOS.iterkeys()):
|
||||
if _id.startswith('fb'):
|
||||
yield self.get_radio(_id)
|
||||
elif len(split_path) == 0:
|
||||
for id in sorted(self._RADIOS.iterkeys()):
|
||||
if not id.startswith('fb'):
|
||||
yield self.get_radio(id)
|
||||
yield Collection('francebleu', self.iter_resources('francebleu'))
|
||||
for _id in sorted(self._RADIOS.iterkeys()):
|
||||
if not _id.startswith('fb'):
|
||||
yield self.get_radio(_id)
|
||||
yield Collection('francebleu', 'France Bleu',
|
||||
children=self.iter_resources(['francebleu']))
|
||||
else:
|
||||
raise CollectionNotFound()
|
||||
raise CollectionNotFound(split_path)
|
||||
|
||||
def iter_radios_search(self, pattern):
|
||||
for radio in self.iter_resources([]):
|
||||
for radio in self._flatten_resources(self.iter_resources([])):
|
||||
if pattern.lower() in radio.title.lower() or pattern.lower() in radio.description.lower():
|
||||
yield radio
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue