commit d829883339e531de1d426b011db9f046829d6966
Author: Paco Esteban <paco@e1e0.net>
Date: Sun, 6 Jun 2021 17:57:39 +0200
initial commit
Diffstat:
6 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,3 @@
+config.ini
+subclient.egg-info
+__pycache__
diff --git a/README.md b/README.md
diff --git a/requirements.txt b/requirements.txt
@@ -0,0 +1 @@
+py-sonic==0.7.9
diff --git a/setup.py b/setup.py
@@ -0,0 +1,36 @@
+from setuptools import setup, find_packages
+import pathlib
+
+here = pathlib.Path(__file__).parent.resolve()
+
+long_description = (here / 'README.md').read_text(encoding='utf-8')
+
+setup(
+ name='subclient',
+ version='0.1.0',
+ description='cli client for a subsonic server',
+ long_description=long_description,
+ long_description_content_type='text/markdown',
+ url='https://git.e1e0.net/subclient/',
+ author='Paco Esteban',
+ author_email='paco@e1e0.net',
+ classifiers=[
+ 'Development Status :: 3 - Alpha',
+ 'License :: OSI Approved :: ISC License',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: 3.9',
+ 'Programming Language :: Python :: 3 :: Only',
+ ],
+ keywords='subsonic, client, music',
+ packages=find_packages(where='.'),
+ python_requires='>=3.6, <4',
+ install_requires=['py-sonic'],
+ entry_points={
+ 'console_scripts': [
+ 'subclient=subclient.subclient:main',
+ ],
+ },
+)
diff --git a/subclient/__init__.py b/subclient/__init__.py
diff --git a/subclient/subclient.py b/subclient/subclient.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import configparser
+import libsonic
+import sys
+
+
+def main():
+ config = configparser.ConfigParser()
+ config.read('config.ini')
+
+ url = config['subsonic']['url']
+ user = config['subsonic']['username']
+ pwd = config['subsonic']['password']
+
+ conn = libsonic.Connection(url, user, pwd, port=443)
+
+ # Let's get 2 completely random songs
+ # songs = conn.getRandomSongs(size=2)
+ # We'll just pretty print the results we got to the terminal
+ # pprint(songs)
+
+ stream = conn.stream('370bce250b179939304f7ac3eed94936', tformat='raw')
+
+ while True:
+ chunk = stream.read(1024)
+ if not chunk:
+ sys.stderr.write("EOF\n")
+ break
+
+ sys.stdout.buffer.write(chunk)
+ # print(dir(stream))
+
+
+if __name__ == "__main__":
+ main()