diff --git a/.gitignore b/.gitignore index fe27dbb..2d52f99 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # generic temporary / dev files *.pyc *.sh +!/alpine_install.sh *.note *.xcf nohup.out diff --git a/README.md b/README.md index a6f0a41..571cc60 100644 --- a/README.md +++ b/README.md @@ -17,30 +17,21 @@ Also neat: You can use your **custom artist or track images**. ## Requirements * Python 3 -* Pip packages specified in `requirements.txt` +* Several Pip packages (automatically downloaded) * If you'd like to display images, you will need API keys for [Last.fm](https://www.last.fm/api/account/create) and [Fanart.tv](https://fanart.tv/get-an-api-key/). These are free of charge! ## How to install -1) Either install Maloja with the [debian package](https://github.com/krateng/maloja/raw/master/packages/maloja.deb), or download the repository to some arbitrary location. If you pick the manual installation, every command needs to be executed from the Maloja directory and led with `./`. You can also only download the file `maloja` instead of the whole repository and fetch the rest with +1) Download Maloja with the command `pip install maloja`. Make sure to use the correct python version (Use `pip3` if necessary). I've provided a simple .sh file to get Maloja going on an Alpine server (e.g. in Proxmox). - ./maloja install - -2) Install required packages with - - pip3 install -r requirements.txt - -3) Start the server with +2) Start the server with maloja start -4) (Recommended) Put your server behind a reverse proxy for SSL encryption. +3) (Recommended) Put your server behind a reverse proxy for SSL encryption. ## How to use -If you didn't install Maloja from the package (and therefore don't have it in `/opt/maloja`), every command needs to be executed from the Maloja directory and led with `./`. Otherwise, all commands work in any location and without the prefix. - - 1) If you would like to import all your previous last.fm scrobbles, use [benfoxall's website](https://benjaminbenben.com/lastfm-to-csv/) ([GitHub page](https://github.com/benfoxall/lastfm-to-csv)). Use the command maloja import *filename* @@ -52,13 +43,12 @@ If you didn't install Maloja from the package (and therefore don't have it in `/ maloja stop maloja restart maloja start - maloja update - The `update` command will always fetch the latest version, while packages are only offered for release versions. +3) Update Maloja with `pip install maloja --upgrade --no-cache-dir` -3) Various folders have `.info` files with more information on how to use their associated features. +4) Various folders have `.info` files with more information on how to use their associated features. -4) If you'd like to implement anything on top of Maloja, visit `/api_explorer`. +5) If you'd like to implement anything on top of Maloja, visit `/api_explorer`. ## How to scrobble diff --git a/alpine_install.sh b/alpine_install.sh new file mode 100644 index 0000000..6fc34cf --- /dev/null +++ b/alpine_install.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +apk add python3 python3-dev gcc libxml2-dev libxslt-dev py3-pip libc-dev +pip3 install maloja diff --git a/maloja/__init__.py b/maloja/__init__.py index 69868b0..505f5ba 100644 --- a/maloja/__init__.py +++ b/maloja/__init__.py @@ -5,7 +5,7 @@ from .info import author,version,versionstr requires = [ "bottle>=0.12.16", "waitress>=1.3", - "doreah>=1.2.7", + "doreah>=1.2.9", "nimrodel>=0.4.9", "setproctitle>=1.1.10", "wand>=0.5.4", diff --git a/maloja/controller.py b/maloja/controller.py index ba03c78..ad4bcc2 100755 --- a/maloja/controller.py +++ b/maloja/controller.py @@ -22,6 +22,7 @@ def yellow(txt): return "\033[93m" + txt + "\033[0m" +origpath = os.getcwd() os.chdir(DATA_DIR) def copy_initial_local_files(): @@ -131,11 +132,10 @@ def stop(): return True -def loadlastfm(): +def loadlastfm(filename): try: - filename = sys.argv[2] - filename = os.path.abspath(filename) + filename = os.path.join(origpath,filename) except: print("Please specify a file!") return @@ -147,19 +147,27 @@ def loadlastfm(): else: return print("Please wait...") - os.system("python3 ./lastfmconverter.py " + filename + " ./scrobbles/lastfmimport.tsv") + os.system("python3 -m maloja.lastfmconverter " + filename + " ./scrobbles/lastfmimport.tsv") print("Successfully imported your Last.FM scrobbles!") +def direct(): + from . import server +from doreah.control import mainfunction -def main(): - if sys.argv[1] == "start": restart() - elif sys.argv[1] == "restart": restart() - elif sys.argv[1] == "stop": stop() - #elif sys.argv[1] == "update": update() - elif sys.argv[1] == "import": loadlastfm() - #elif sys.argv[1] == "install": installhere() - else: print("Valid commands: start restart stop import") +@mainfunction({},shield=True) +def main(action,*args,**kwargs): + actions = { + "start":restart, + "restart":restart, + "stop":stop, + "import":loadlastfm, + "debug":direct + } + if action in actions: actions[action](*args,**kwargs) + else: print("Valid commands: " + " ".join(a for a in actions)) + + return True -if __name__ == "__main__": - main() +#if __name__ == "__main__": +# main() diff --git a/maloja/info.py b/maloja/info.py index 55c2894..6fc7dac 100644 --- a/maloja/info.py +++ b/maloja/info.py @@ -5,7 +5,7 @@ author = { "email":"maloja@krateng.dev", "github": "krateng" } -version = 2,0,0 +version = 2,0,1 versionstr = ".".join(str(n) for n in version) diff --git a/packages/maloja.deb b/packages/maloja.deb deleted file mode 100644 index efd5cea..0000000 Binary files a/packages/maloja.deb and /dev/null differ