diff --git a/conf/mopidy.conf b/conf/mopidy.conf index 5f0d286..8731282 100644 --- a/conf/mopidy.conf +++ b/conf/mopidy.conf @@ -44,7 +44,7 @@ [mpd] enabled = true -hostname = 127.0.0.1 +hostname = __IPLOCAL__ port = 6600 #password = max_connections = 20 @@ -57,7 +57,7 @@ default_playlist_scheme = m3u [http] enabled = true -hostname = 127.0.0.1 +hostname = __IPLOCAL__ port = 6680 #static_dir = zeroconf = Mopidy HTTP server on $hostname @@ -111,4 +111,18 @@ excluded_file_extensions = .log .nfo .png - .txt \ No newline at end of file + .txt + +[spotify] +username = __USER_SPOTIFY__ +password = __PWD_SPOTIFY__ +#bitrate = 320 +#timeout = 10 +#cache_dir = $XDG_CACHE_DIR/mopidy/spotify + +[spotify_web] +client_id = __ID_SPOTIFY__ +client_secret = __SECRET_SPOTIFY__ + +[soundcloud] +auth_token = __SOUNDCLOUD__ \ No newline at end of file diff --git a/manifest.json b/manifest.json index aa6ad39..59286ba 100644 --- a/manifest.json +++ b/manifest.json @@ -39,6 +39,66 @@ "fr": "Administrateur de Mopidy (doit être un utilisateur YunoHost existant)" }, "example": "johndoe" + }, + { + "name": "is_spotify", + "ask": { + "en": "You want to use Spotify ?", + "fr": "Voulez vous utiliser Spotify ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + }, + { + "name": "spotify_user", + "type": "user", + "ask": { + "en": "User Spotify", + "fr": "Utilisateur Spotify" + }, + "example": "johndoe" + }, + { + "name": "spotify_pass", + "type": "password", + "ask": { + "en": "Password Spotify", + "fr": "Mot de passe Spotify" + }, + "example": "myreallystrengthpassword" + }, + { + "name": "spotify_id", + "type": "id", + "ask": { + "en": "client ID Spotify", + "fr": "ID client Spotify" + } + }, + { + "name": "spotify_id_secret", + "type": "id", + "ask": { + "en": "client secret ID Spotify", + "fr": "ID client secret Spotify" + } + }, + { + "name": "is_soundcloud", + "ask": { + "en": "You want to use Soundcloud ?", + "fr": "Voulez vous utiliser Soundcloud ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + }, + { + "name": "soundcloud_id", + "type": "id", + "ask": { + "en": "Soundcloud ID Spotify", + "fr": "ID Soundcloud Spotify" + } } ] } diff --git a/scripts/install b/scripts/install index f9293e5..2f92c25 100644 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,18 @@ TRAP_ON # Active trap pour arrêter le script si une erreur est détectée. domain=$YNH_APP_ARG_DOMAIN admin_mopidy=$YNH_APP_ARG_ADMIN_MOPIDY +if [ "$is_spotify" = "Yes" ]; +then + spotify_user=$YNH_APP_ARG_SPOTIFY_USER + spotify_pass=$YNH_APP_ARG_SPOTIFY_PASS + spotify_id=$YNH_APP_ARG_SPOTIFY_ID + spotify_id_secret=$YNH_APP_ARG_SPOTIFY_ID_SECRET +fi + +if [ "$is_soundcloud" = "Yes" ]; +then + soundcloud_id=$YNH_APP_ARG_SOUNDCLOUD_ID +fi app=$YNH_APP_INSTANCE_NAME @@ -24,6 +36,19 @@ CHECK_USER "$admin_mopidy" ynh_app_setting_set $app domain $domain ynh_app_setting_set $app admin $admin_mopidy +if [ "$is_spotify" = "Yes" ]; +then + ynh_app_setting_set $app spotify_user $spotify_user + ynh_app_setting_set $app spotify_pass $spotify_pass + ynh_app_setting_set $app spotify_id $spotify_id + ynh_app_setting_set $app spotify_id_secret $spotify_id_secret +fi + +if [ "$is_soundcloud" = "Yes" ]; +then + ynh_app_setting_set $app soundcloud_id $soundcloud_id +fi + # Add the archive’s GPG key: wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add - @@ -35,7 +60,32 @@ sudo apt-get update sudo apt-get install -y mopidy # Copy configuration -sudo cp ../conf/mopidy.conf /root/.config/mopidy/ +sudo rm -fr /root/.config/mopidy/ +ip_local=$(echo hostname -I | awk '{ print $1 }') +sudo sed -i "s@__IPLOCAL__@$ip_local@g" ../conf/mopidy.conf + +if [ "$is_spotify" = "Yes" ]; +then + sudo sed -i '/[spotify]/r enabled = true' ../conf/mopidy.conf + sudo sed -i "s@__USER_SPOTIFY__@$spotify_user@g" ../conf/mopidy.conf + sudo sed -i "s@__PWD_SPOTIFY__@$spotify_pass@g" ../conf/mopidy.conf + sudo sed -i "s@__ID_SPOTIFY__@$spotify_id@g" ../conf/mopidy.conf + sudo sed -i "s@__SECRET_SPOTIFY__@$spotify_id_secret@g" ../conf/mopidy.conf +else + sudo sed -i "s@__USER_SPOTIFY__@@g" ../conf/mopidy.conf + sudo sed -i "s@__PWD_SPOTIFY__@@g" ../conf/mopidy.conf + sudo sed -i "s@__ID_SPOTIFY__@@g" ../conf/mopidy.conf + sudo sed -i "s@__SECRET_SPOTIFY__@@g" ../conf/mopidy.conf +fi + +if [ "$is_soundcloud" = "Yes" ]; +then + sudo sed -i "s@__SOUNDCLOUD__@$soundcloud_id@g" ../conf/mopidy.conf +else + sudo sed -i "s@__SOUNDCLOUD__@@g" ../conf/mopidy.conf +fi + +sudo cp ../conf/mopidy.conf /usr/share/mopidy/conf.d/ # Running Mopidy as a service sudo mopidy local scan @@ -48,4 +98,8 @@ cd /tmp/ sudo git clone https://github.com/pimusicbox/mopidy-musicbox-webclient cd mopidy-musicbox-webclient sudo python setup.py install -sudo rm -fr mopidy-musicbox-webclient \ No newline at end of file +sudo rm -fr mopidy-musicbox-webclient + +# Allow port +sudo yunohost firewall allow TCP 6600 +sudo yunohost firewall allow TCP 6680 \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 02f8867..eca0685 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,11 +8,17 @@ source .fonctions # Charge les fonctions génériques habituellement utilisées # Source app helpers source /usr/share/yunohost/helpers -# Récupère les infos de l'application. +# Get application informations app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) +# Remove application sudo apt-get remove --purge -y mopidy +sudo pip uninstall mopidy_musicbox_webclient + +# disallow firewall port +sudo yunohost firewall disallow 6600 +sudo yunohost firewall disallow 6680 # Régénère la configuration de SSOwat sudo yunohost app ssowatconf