[audio] add specific filters in order to create audio objects id / browser2 adaptation : do not require an id in constructor
This commit is contained in:
parent
985708f10a
commit
d020741a4b
1 changed files with 25 additions and 9 deletions
|
|
@ -21,6 +21,7 @@ import re
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
|
from weboob.browser.filters.standard import Format
|
||||||
from .image import BaseImage
|
from .image import BaseImage
|
||||||
from .base import Field, StringField, IntField, BaseObject
|
from .base import Field, StringField, IntField, BaseObject
|
||||||
from .file import CapFile, BaseFile
|
from .file import CapFile, BaseFile
|
||||||
|
|
@ -44,6 +45,14 @@ def decode_id(decode_id):
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
class AlbumIdFilter(Format):
|
||||||
|
"""
|
||||||
|
Filter that help to fill Albums id field
|
||||||
|
"""
|
||||||
|
def __init__(self, *args):
|
||||||
|
super(AlbumIdFilter, self).__init__(u'album.%s', *args)
|
||||||
|
|
||||||
|
|
||||||
class Album(BaseObject):
|
class Album(BaseObject):
|
||||||
"""
|
"""
|
||||||
Represent an album
|
Represent an album
|
||||||
|
|
@ -54,9 +63,6 @@ class Album(BaseObject):
|
||||||
thumbnail = Field('Image associated to the album', BaseImage)
|
thumbnail = Field('Image associated to the album', BaseImage)
|
||||||
tracks_list = Field('list of tracks', list)
|
tracks_list = Field('list of tracks', list)
|
||||||
|
|
||||||
def __init__(self, _id):
|
|
||||||
BaseObject.__init__(self, unicode("album.%s" % _id))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def decode_id(cls, _id):
|
def decode_id(cls, _id):
|
||||||
if _id:
|
if _id:
|
||||||
|
|
@ -66,6 +72,14 @@ class Album(BaseObject):
|
||||||
return _id
|
return _id
|
||||||
|
|
||||||
|
|
||||||
|
class PlaylistIdFilter(Format):
|
||||||
|
"""
|
||||||
|
Filter that help to fill Albums id field
|
||||||
|
"""
|
||||||
|
def __init__(self, *args):
|
||||||
|
super(PlaylistIdFilter, self).__init__(u'playlist.%s', *args)
|
||||||
|
|
||||||
|
|
||||||
class Playlist(BaseObject):
|
class Playlist(BaseObject):
|
||||||
"""
|
"""
|
||||||
Represent a playlist
|
Represent a playlist
|
||||||
|
|
@ -73,9 +87,6 @@ class Playlist(BaseObject):
|
||||||
title = StringField('playlist name')
|
title = StringField('playlist name')
|
||||||
tracks_list = Field('list of tracks', list)
|
tracks_list = Field('list of tracks', list)
|
||||||
|
|
||||||
def __init__(self, _id):
|
|
||||||
BaseObject.__init__(self, unicode("playlist.%s" % _id))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def decode_id(cls, _id):
|
def decode_id(cls, _id):
|
||||||
if _id:
|
if _id:
|
||||||
|
|
@ -85,6 +96,14 @@ class Playlist(BaseObject):
|
||||||
return _id
|
return _id
|
||||||
|
|
||||||
|
|
||||||
|
class BaseAudioIdFilter(Format):
|
||||||
|
"""
|
||||||
|
Filter that help to fill Albums id field
|
||||||
|
"""
|
||||||
|
def __init__(self, *args):
|
||||||
|
super(BaseAudioIdFilter, self).__init__(u'audio.%s', *args)
|
||||||
|
|
||||||
|
|
||||||
class BaseAudio(BaseFile):
|
class BaseAudio(BaseFile):
|
||||||
"""
|
"""
|
||||||
Represent an audio file
|
Represent an audio file
|
||||||
|
|
@ -94,9 +113,6 @@ class BaseAudio(BaseFile):
|
||||||
format = StringField('file format')
|
format = StringField('file format')
|
||||||
thumbnail = Field('Image associated to the file', BaseImage)
|
thumbnail = Field('Image associated to the file', BaseImage)
|
||||||
|
|
||||||
def __init__(self, _id):
|
|
||||||
BaseFile.__init__(self, unicode("audio.%s" % _id))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def decode_id(cls, _id):
|
def decode_id(cls, _id):
|
||||||
if _id:
|
if _id:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue