Server improvements
This commit is contained in:
@@ -6,8 +6,13 @@ gi.require_version('Gtk', '3.0')
|
|||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from .app import LibremsonicApp
|
from .app import LibremsonicApp
|
||||||
|
from .server import Server
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = LibremsonicApp()
|
server = Server('ohea', 'https://airsonic.the-evans.family', 'sumner',
|
||||||
app.run(sys.argv)
|
'O}/UieSb[nzZ~l[X1S&zzX1Hi')
|
||||||
|
|
||||||
|
print(server.get_license())
|
||||||
|
# app = LibremsonicApp()
|
||||||
|
# app.run(sys.argv)
|
||||||
|
@@ -39,20 +39,31 @@ class ServerConfiguration:
|
|||||||
class AppConfiguration:
|
class AppConfiguration:
|
||||||
servers: List[ServerConfiguration]
|
servers: List[ServerConfiguration]
|
||||||
current_server: int
|
current_server: int
|
||||||
cache_location: str
|
permanent_cache_location: str
|
||||||
music_storage_location: str
|
temporary_cache_location: str
|
||||||
|
max_cache_size_mb: int # -1 means unlimited
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return {
|
return {
|
||||||
'servers': [s.__dict__ for s in self.servers],
|
'servers': [s.__dict__ for s in self.servers],
|
||||||
'current_server': self.current_server,
|
'current_server': self.current_server,
|
||||||
|
'permanent_cache_location': self.permanent_cache_location,
|
||||||
|
'temporary_cache_location': self.temporary_cache_location,
|
||||||
|
'max_cache_size_mb': self.max_cache_size_mb,
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_default_configuration(cls):
|
def get_default_configuration(cls):
|
||||||
|
default_cache_location = (os.environ.get('XDG_DATA_HOME')
|
||||||
|
or os.path.expanduser('~/.local/share'))
|
||||||
|
default_cache_location = os.path.join(default_cache_location,
|
||||||
|
'libremsonic')
|
||||||
config = AppConfiguration()
|
config = AppConfiguration()
|
||||||
config.servers = []
|
config.servers = []
|
||||||
config.current_server = -1
|
config.current_server = -1
|
||||||
|
config.permanent_cache_location = default_cache_location
|
||||||
|
config.temporary_cache_location = config.permanent_cache_location
|
||||||
|
config.max_cache_size_mb = -1
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
@@ -41,29 +41,42 @@ class MusicFolder(APIObject):
|
|||||||
id: int
|
id: int
|
||||||
name: str
|
name: str
|
||||||
|
|
||||||
|
class MediaType(APIObject, Enum):
|
||||||
|
|
||||||
|
|
||||||
class File(APIObject):
|
|
||||||
id: int
|
class Child(APIObject):
|
||||||
parent: int
|
id: str
|
||||||
title: str
|
parent: str
|
||||||
isDir: bool
|
isDir: bool
|
||||||
|
title: str
|
||||||
album: str
|
album: str
|
||||||
artist: str
|
artist: str
|
||||||
track: str
|
track: int
|
||||||
year: str
|
year: int
|
||||||
genre: str
|
genre: str
|
||||||
coverArt: int
|
coverArt: str
|
||||||
size: int
|
size: int
|
||||||
contentType: str
|
contentType: str
|
||||||
isVideo: bool
|
|
||||||
transcodedSuffix: str
|
|
||||||
transcodedContentType: str
|
|
||||||
suffix: str
|
suffix: str
|
||||||
|
transcodedContentType: str
|
||||||
|
transcodedSuffix: str
|
||||||
duration: int
|
duration: int
|
||||||
bitRate: int
|
bitRate: int
|
||||||
path: str
|
path: str
|
||||||
|
isVideo: bool
|
||||||
|
userRating: UserRating
|
||||||
|
averageRating: AverageRating
|
||||||
playCount: int
|
playCount: int
|
||||||
|
discNumber: int
|
||||||
created: datetime
|
created: datetime
|
||||||
|
starred: datetime
|
||||||
|
albumId: str
|
||||||
|
artistId: str
|
||||||
|
type: MediaType
|
||||||
|
bookmarkPosition: int
|
||||||
|
originalWidth: int
|
||||||
|
originalHeight: int
|
||||||
|
|
||||||
|
|
||||||
class Album(APIObject):
|
class Album(APIObject):
|
||||||
@@ -78,20 +91,67 @@ class Album(APIObject):
|
|||||||
year: str
|
year: str
|
||||||
genre: str
|
genre: str
|
||||||
|
|
||||||
song: List[File]
|
song: List[Child]
|
||||||
|
|
||||||
|
|
||||||
|
class AlbumID3(APIObject):
|
||||||
|
id: str
|
||||||
|
name: str
|
||||||
|
artist: str
|
||||||
|
artistId: str
|
||||||
|
coverArt: str
|
||||||
|
songCount: int
|
||||||
|
duration: int
|
||||||
|
playCount: int
|
||||||
|
created: datetime
|
||||||
|
starred: datetime
|
||||||
|
year: int
|
||||||
|
genre: str
|
||||||
|
|
||||||
|
|
||||||
|
class AlbumWithSongsID3(APIObject):
|
||||||
|
id: str
|
||||||
|
name: str
|
||||||
|
artist: str
|
||||||
|
artistId: str
|
||||||
|
coverArt: str
|
||||||
|
songCount: int
|
||||||
|
duration: int
|
||||||
|
playCount: int
|
||||||
|
created: datetime
|
||||||
|
starred: datetime
|
||||||
|
year: int
|
||||||
|
genre: str
|
||||||
|
|
||||||
|
song: List[Child]
|
||||||
|
|
||||||
|
|
||||||
class Artist(APIObject):
|
class Artist(APIObject):
|
||||||
id: int
|
id: str
|
||||||
|
name: str
|
||||||
|
artistImageUrl: str
|
||||||
|
starred: datetime
|
||||||
|
userRating: UserRating
|
||||||
|
averageRating: AverageRating
|
||||||
|
|
||||||
|
|
||||||
|
class ArtistID3(APIObject):
|
||||||
|
id: str
|
||||||
name: str
|
name: str
|
||||||
coverArt: str
|
coverArt: str
|
||||||
|
artistImageUrl: str
|
||||||
albumCount: int
|
albumCount: int
|
||||||
album: List[Album]
|
starred: datetime
|
||||||
|
|
||||||
|
|
||||||
class Shortcut(APIObject):
|
class ArtistWithAlbumsID3(APIObject):
|
||||||
id: int
|
id: str
|
||||||
name: str
|
name: str
|
||||||
|
coverArt: str
|
||||||
|
artistImageUrl: str
|
||||||
|
albumCount: int
|
||||||
|
starred: datetime
|
||||||
|
album: List[AlbumID3]
|
||||||
|
|
||||||
|
|
||||||
class Index(APIObject):
|
class Index(APIObject):
|
||||||
@@ -99,47 +159,34 @@ class Index(APIObject):
|
|||||||
artist: List[Artist]
|
artist: List[Artist]
|
||||||
|
|
||||||
|
|
||||||
|
class IndexID3(APIObject):
|
||||||
|
name: str
|
||||||
|
artist: List[ArtistID3]
|
||||||
|
|
||||||
|
|
||||||
class Indexes(APIObject):
|
class Indexes(APIObject):
|
||||||
lastModified: int
|
lastModified: int
|
||||||
ignoredArticles: str
|
ignoredArticles: str
|
||||||
index: List[Index]
|
index: List[Index]
|
||||||
shortcut: List[Shortcut]
|
shortcut: List[Artist]
|
||||||
child: List[File]
|
child: List[Child]
|
||||||
|
|
||||||
|
|
||||||
class Directory(APIObject):
|
class Directory(APIObject):
|
||||||
id: int
|
id: str
|
||||||
parent: str
|
parent: str
|
||||||
name: str
|
name: str
|
||||||
|
starred: datetime
|
||||||
|
userRating: UserRating
|
||||||
|
averageRating: AverageRating
|
||||||
playCount: int
|
playCount: int
|
||||||
child: List[File]
|
|
||||||
|
child: List[Child]
|
||||||
|
|
||||||
|
|
||||||
class Genre(APIObject):
|
class Genre(APIObject):
|
||||||
songCount: int
|
songCount: int
|
||||||
albumCount: int
|
albumCount: int
|
||||||
vvalue: str
|
|
||||||
|
|
||||||
|
|
||||||
class MusicFolders(APIObject):
|
|
||||||
musicFolder: List[MusicFolder]
|
|
||||||
|
|
||||||
|
|
||||||
class Genres(APIObject):
|
|
||||||
genre: List[Genre]
|
|
||||||
|
|
||||||
|
|
||||||
class Artists(APIObject):
|
|
||||||
index: List[Index]
|
|
||||||
|
|
||||||
|
|
||||||
class Videos(APIObject):
|
|
||||||
video: List[File]
|
|
||||||
|
|
||||||
|
|
||||||
class VideoInfo(APIObject):
|
|
||||||
# TODO implement when I have videos
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ArtistInfo(APIObject):
|
class ArtistInfo(APIObject):
|
||||||
@@ -161,27 +208,109 @@ class AlbumInfo(APIObject):
|
|||||||
largeImageUrl: str
|
largeImageUrl: str
|
||||||
|
|
||||||
|
|
||||||
|
class Captions(APIObject):
|
||||||
|
id: str
|
||||||
|
name: str
|
||||||
|
|
||||||
|
|
||||||
|
class AudioTrack(APIObject):
|
||||||
|
id: str
|
||||||
|
name: str
|
||||||
|
languageCode: str
|
||||||
|
|
||||||
|
|
||||||
|
class VideoConversion(APIObject):
|
||||||
|
id: str
|
||||||
|
bitRate: int
|
||||||
|
audioTrackId: int
|
||||||
|
|
||||||
|
|
||||||
|
class VideoInfo(APIObject):
|
||||||
|
id: str
|
||||||
|
captions: List[Captions]
|
||||||
|
audioTrack: List[AudioTrack]
|
||||||
|
conversion: List[VideoConversion]
|
||||||
|
|
||||||
|
|
||||||
|
class ArtistsID3(APIObject):
|
||||||
|
ignoredArticles: str
|
||||||
|
index: List[IndexID3]
|
||||||
|
|
||||||
|
|
||||||
|
class MusicFolders(APIObject):
|
||||||
|
musicFolder: List[MusicFolder]
|
||||||
|
|
||||||
|
|
||||||
|
class Genres(APIObject):
|
||||||
|
genre: List[Genre]
|
||||||
|
|
||||||
|
|
||||||
|
class Artists(APIObject):
|
||||||
|
index: List[Index]
|
||||||
|
|
||||||
|
|
||||||
|
class Videos(APIObject):
|
||||||
|
video: List[Child]
|
||||||
|
|
||||||
|
|
||||||
class SimilarSongs(APIObject):
|
class SimilarSongs(APIObject):
|
||||||
song: List[File]
|
song: List[Child]
|
||||||
|
|
||||||
|
|
||||||
|
class TopSongs(APIObject):
|
||||||
|
song: List[Child]
|
||||||
|
|
||||||
|
|
||||||
|
class AlbumList(APIObject):
|
||||||
|
album: List[Album]
|
||||||
|
|
||||||
|
|
||||||
class SubsonicResponse(APIObject):
|
class SubsonicResponse(APIObject):
|
||||||
|
# On every Subsonic Response
|
||||||
status: str
|
status: str
|
||||||
version: str
|
version: str
|
||||||
license: License
|
|
||||||
error: SubsonicError
|
# One of these will exist on each SubsonicResponse
|
||||||
musicFolders: MusicFolders
|
album: AlbumWithSongsID3
|
||||||
indexes: Indexes
|
albumInfo: AlbumInfo
|
||||||
|
albumList: AlbumList
|
||||||
|
albumList2: AlbumList2
|
||||||
|
artist: ArtistWithAlbumsID3
|
||||||
|
artistInfo: ArtistInfo
|
||||||
|
artistInfo2: ArtistInfo2
|
||||||
|
artists: ArtistsID3
|
||||||
|
bookmarks: Bookmarks
|
||||||
|
chatMessages: ChatMessages
|
||||||
directory: Directory
|
directory: Directory
|
||||||
|
error: Error
|
||||||
genres: Genres
|
genres: Genres
|
||||||
artists: Artists
|
indexes: Indexes
|
||||||
artist: Artist
|
internetRadioStations: InternetRadioStations
|
||||||
album: Album
|
jukeboxPlaylist: JukeboxPlaylist
|
||||||
song: File
|
jukeboxStatus: JukeboxStatus
|
||||||
|
license: License
|
||||||
|
lyrics: Lyrics
|
||||||
|
musicFolders: MusicFolders
|
||||||
|
newestPodcasts: NewestPodcasts
|
||||||
|
nowPlaying: NowPlaying
|
||||||
|
playlist: PlaylistWithSongs
|
||||||
|
playlists: Playlists
|
||||||
|
playQueue: PlayQueue
|
||||||
|
podcasts: Podcasts
|
||||||
|
randomSongs: Songs
|
||||||
|
scanStatus: ScanStatus
|
||||||
|
searchResult: SearchResult
|
||||||
|
searchResult2: SearchResult2
|
||||||
|
searchResult3: SearchResult3
|
||||||
|
shares: Shares
|
||||||
|
similarSongs: SimilarSongs
|
||||||
|
similarSongs2: SimilarSongs2
|
||||||
|
song: Child
|
||||||
|
songsByGenre: Songs
|
||||||
|
starred: Starred
|
||||||
|
starred2: Starred2
|
||||||
|
topSongs: TopSongs
|
||||||
|
user: User
|
||||||
|
users: Users
|
||||||
videos: Videos
|
videos: Videos
|
||||||
videoInfo: VideoInfo
|
videoInfo: VideoInfo
|
||||||
artistInfo: ArtistInfo
|
|
||||||
artistInfo2: ArtistInfo
|
|
||||||
albumInfo: AlbumInfo
|
|
||||||
albumInfo2: AlbumInfo
|
|
||||||
similarSongs: SimilarSongs
|
|
||||||
|
@@ -246,5 +246,78 @@ class Server:
|
|||||||
:param count: Max number of songs to return. Defaults to 50 according
|
:param count: Max number of songs to return. Defaults to 50 according
|
||||||
to API Spec.
|
to API Spec.
|
||||||
"""
|
"""
|
||||||
result = self._post(self._make_url('getAlbumInfo2'), id=id)
|
result = self._post(self._make_url('getSimilarSongs'),
|
||||||
|
id=id,
|
||||||
|
count=count)
|
||||||
return result.similarSongs.song
|
return result.similarSongs.song
|
||||||
|
|
||||||
|
def get_similar_songs2(self, id: int, count: int = None) -> List[File]:
|
||||||
|
"""
|
||||||
|
Similar to getSimilarSongs, but organizes music according to ID3 tags.
|
||||||
|
|
||||||
|
:param id: The artist, album or song ID.
|
||||||
|
:param count: Max number of songs to return. Defaults to 50 according
|
||||||
|
to API Spec.
|
||||||
|
"""
|
||||||
|
result = self._post(self._make_url('getSimilarSongs2'),
|
||||||
|
id=id,
|
||||||
|
count=count)
|
||||||
|
return result.similarSongs2.song
|
||||||
|
|
||||||
|
def get_top_songs(self, artist: str, count: int = None) -> List[File]:
|
||||||
|
"""
|
||||||
|
Returns top songs for the given artist, using data from last.fm.
|
||||||
|
|
||||||
|
:param id: The artist name.
|
||||||
|
:param count: Max number of songs to return. Defaults to 50 according
|
||||||
|
to API Spec.
|
||||||
|
"""
|
||||||
|
result = self._post(self._make_url('getTopSongs'),
|
||||||
|
artist=artist,
|
||||||
|
count=count)
|
||||||
|
return result.topSongs.song
|
||||||
|
|
||||||
|
def get_album_list(self,
|
||||||
|
type: str,
|
||||||
|
size: int = None,
|
||||||
|
offset: int = None,
|
||||||
|
from_year: int = None,
|
||||||
|
to_year: int = None,
|
||||||
|
genre: str = None,
|
||||||
|
music_folder_id: int = None) -> List[File]:
|
||||||
|
"""
|
||||||
|
Returns a list of random, newest, highest rated etc. albums. Similar to
|
||||||
|
the album lists on the home page of the Subsonic web interface.
|
||||||
|
|
||||||
|
:param type: The list type. Must be one of the following: ``random``,
|
||||||
|
``newest``, ``highest``, ``frequent``, ``recent``. Since 1.8.0 you
|
||||||
|
can also use ``alphabeticalByName`` or ``alphabeticalByArtist`` to
|
||||||
|
page through all albums alphabetically, and ``starred`` to retrieve
|
||||||
|
starred albums. Since 1.10.1 you can use ``byYear`` and
|
||||||
|
``byGenre`` to list albums in a given year range or genre.
|
||||||
|
:param size: The number of albums to return. Max 500. Deafult is 10
|
||||||
|
according to API Spec.
|
||||||
|
:param offset: The list offset. Useful if you for example want to page
|
||||||
|
through the list of newest albums. Default is 0 according to API
|
||||||
|
Spec.
|
||||||
|
:param from_year: Required if ``type`` is ``byYear``. The first year in
|
||||||
|
the range. If ``fromYear > toYear`` a reverse chronological list is
|
||||||
|
returned.
|
||||||
|
:param to_year: Required if ``type`` is ``byYear``. The last year in
|
||||||
|
the range.
|
||||||
|
:param genre: Required if ``type`` is ``byGenre``. The name of the
|
||||||
|
genre, e.g., "Rock".
|
||||||
|
:param music_folder_id: (Since 1.11.0) Only return albums in the music
|
||||||
|
folder with the given ID. See ``getMusicFolders``.
|
||||||
|
"""
|
||||||
|
result = self._post(
|
||||||
|
self._make_url('getAlbumList'),
|
||||||
|
type=type,
|
||||||
|
size=size,
|
||||||
|
offset=offset,
|
||||||
|
fromYear=from_year,
|
||||||
|
toYear=to_year,
|
||||||
|
genre=genre,
|
||||||
|
musicFolderId=music_folder_id,
|
||||||
|
)
|
||||||
|
return result.albumList
|
||||||
|
Reference in New Issue
Block a user