a b/src/cdplugins/tidal/tidalapi/models.py
1
# -*- coding: utf-8 -*-
2
#
3
# Copyright (C) 2014 Thomas Amland
4
#
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License as published by
7
# the Free Software Foundation, either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU Lesser General Public License for more details.
14
#
15
# You should have received a copy of the GNU Lesser General Public License
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
19
from __future__ import unicode_literals
20
from enum import Enum
21
22
IMG_URL = "http://images.osl.wimpmusic.com/im/im?w={width}&h={height}&{id_type}={id}"
23
24
25
class Model(object):
26
    id = None
27
    name = None
28
29
    def __init__(self, **kwargs):
30
        self.__dict__.update(kwargs)
31
32
33
class Album(Model):
34
    artist = None
35
    artists = []
36
    num_tracks = -1
37
    duration = -1
38
    release_date = None
39
40
    @property
41
    def image(self, width=512, height=512):
42
        return IMG_URL.format(width=width, height=height, id=self.id, id_type='albumid')
43
44
45
class Artist(Model):
46
    role = None
47
48
    @property
49
    def image(self, width=512, height=512):
50
        return IMG_URL.format(width=width, height=height, id=self.id, id_type='artistid')
51
52
53
class Playlist(Model):
54
    description = None
55
    creator = None
56
    type = None
57
    is_public = None
58
    created = None
59
    last_updated = None
60
    num_tracks = -1
61
    duration = -1
62
63
    @property
64
    def image(self, width=512, height=512):
65
        return IMG_URL.format(width=width, height=height, id=self.id, id_type='uuid')
66
67
68
class Track(Model):
69
    duration = -1
70
    track_num = -1
71
    disc_num = 1
72
    popularity = -1
73
    artist = None
74
    artists = []
75
    album = None
76
    available = True
77
78
79
class SearchResult(Model):
80
    artists = []
81
    albums = []
82
    tracks = []
83
    playlists = []
84
85
86
class Category(Model):
87
    image = None
88
89
90
class Role(Enum):
91
    main = 'MAIN'
92
    featured = 'FEATURED'