|
@@ -1,6 +1,11 @@
|
|
|
|
+# Lidarr has trouble moving Music without a pre-existing artist folder.
|
|
|
|
+#
|
|
# */1 * * * * /usr/bin/run-one /usr/bin/python3 /path/to/lidarr_empty_folders.py <lidarr IP>:8686 <API key> /path/to/Music/ 2>&1 | /usr/bin/logger -t lidarr_empty_folders
|
|
# */1 * * * * /usr/bin/run-one /usr/bin/python3 /path/to/lidarr_empty_folders.py <lidarr IP>:8686 <API key> /path/to/Music/ 2>&1 | /usr/bin/logger -t lidarr_empty_folders
|
|
|
|
+# Or run it in a k8s cronjob. See lidarr-empty-folders.yaml
|
|
|
|
+# kubectl -n plex create configmap lidarr-empty-folders --from-file=lidarr_empty_folders.py
|
|
|
|
|
|
import requests
|
|
import requests
|
|
|
|
+from requests.adapters import HTTPAdapter, Retry
|
|
import os
|
|
import os
|
|
import sys
|
|
import sys
|
|
if len(sys.argv) != 4:
|
|
if len(sys.argv) != 4:
|
|
@@ -9,7 +14,13 @@ if len(sys.argv) != 4:
|
|
|
|
|
|
lidarr_server, lidarr_api_key, music_folder = sys.argv[1:4]
|
|
lidarr_server, lidarr_api_key, music_folder = sys.argv[1:4]
|
|
|
|
|
|
-resp = requests.get(
|
|
|
|
|
|
+
|
|
|
|
+retries = Retry(total=10,
|
|
|
|
+ backoff_factor=1,
|
|
|
|
+ status_forcelist=[ 500, 502, 503, 504 ])
|
|
|
|
+s = requests.Session()
|
|
|
|
+s.mount('http://', HTTPAdapter(max_retries=retries))
|
|
|
|
+resp = s.get(
|
|
f"{lidarr_server}/api/v1/artist",
|
|
f"{lidarr_server}/api/v1/artist",
|
|
headers={"Authorization": f"Bearer {lidarr_api_key}"}
|
|
headers={"Authorization": f"Bearer {lidarr_api_key}"}
|
|
)
|
|
)
|