Added todo

This commit is contained in:
Sumner Evans
2019-06-04 18:45:10 -06:00
parent bb9a7c0392
commit 0177b3ade2
5 changed files with 17 additions and 24 deletions

View File

@@ -1,4 +1,6 @@
#! /usr/bin/env python3
import asyncio
import threading
import argparse
import sys
@@ -16,19 +18,7 @@ def main():
username=sys.argv[1],
password=sys.argv[2])
# print(server.ping())
# print(server.get_license())
# print(server.get_music_folders())
# print(server.get_indexes())
# print(server.get_music_directory(581))
# print(server.get_genres())
# print(server.get_artists())
# print(server.get_artist(20))
# print(server.get_album(31))
# print(server.get_song(203))
print(server.get_artist_info(20))
# win = MainWindow()
# win.connect("destroy", Gtk.main_quit)
# win.show_all()
# Gtk.main()
win = MainWindow(server)
win.connect("destroy", Gtk.main_quit)
win.show_all()
Gtk.main()

View File

@@ -33,6 +33,8 @@ def _from_json(cls, data):
# Having to use this because things changed in Python 3.7.
class_name = cls._name
# TODO: this is not very elegant since it doesn't allow things which
# sublass from List or Dict.
if class_name == 'List':
list_type = cls.__args__[0]
instance: List[list_type] = list()

View File

@@ -1,5 +1,6 @@
import requests
from typing import List, Optional, Dict
from asyncio import sleep
from typing import List, Optional, Dict, Awaitable
from .api_objects import (SubsonicResponse, License, MusicFolder, Indexes,
AlbumInfo, ArtistInfo, VideoInfo, File, Album,
@@ -33,7 +34,7 @@ class Server:
def _make_url(self, endpoint: str) -> str:
return f'{self.hostname}/rest/{endpoint}.view'
def _post(self, url, **params) -> SubsonicResponse:
async def _post(self, url, **params) -> SubsonicResponse:
"""
Make a post to a *Sonic REST API. Handle all types of errors including
*Sonic ``<error>`` responses.
@@ -64,11 +65,11 @@ class Server:
return response
def ping(self) -> SubsonicResponse:
async def ping(self) -> SubsonicResponse:
"""
Used to test connectivity with the server.
"""
return self._post(self._make_url('ping'))
return await self._post(self._make_url('ping'))
def get_license(self) -> License:
"""
@@ -249,4 +250,4 @@ class Server:
to API Spec.
"""
result = self._post(self._make_url('getAlbumInfo2'), id=id)
return result.similarSongs
return result.similarSongs.song

View File

@@ -5,7 +5,7 @@ from gi.repository import Gio, Gtk
class AlbumsPanel(Gtk.Box):
"""Defines the albums panel."""
def __init__(self):
def __init__(self, server):
Gtk.Container.__init__(self)
albums = Gtk.Label('Albums')

View File

@@ -8,7 +8,7 @@ from .albums import AlbumsPanel
class MainWindow(Gtk.Window):
"""Defines the main window for LibremSonic."""
def __init__(self):
def __init__(self, server):
Gtk.Window.__init__(self, title="LibremSonic")
self.set_default_size(400, 200)
@@ -18,7 +18,7 @@ class MainWindow(Gtk.Window):
# Create the stack
stack = self.create_stack(
Albums=AlbumsPanel(),
Albums=AlbumsPanel(server),
Artists=artists,
Playlists=playlists,
More=more,