更新 plugin/NavidromePlaylistSync/sync.py
Some checks failed
continuous-integration/drone Build is failing

This commit is contained in:
mol
2024-11-06 14:52:13 +00:00
parent 88c62f3b97
commit 27490823d6

View File

@ -1,30 +1,30 @@
import os import os
from webdav3.client import Client from webdav3.client import Client
from webdav3.exceptions import LocalResourceNotFound, RemoteResourceNotFound, ResponseErrorCode from webdav3.exceptions import LocalResourceNotFound, RemoteResourceNotFound, ResponseErrorCode
def sync(): def sync():
options = { options = {
'webdav_hostname': 'https://pan.liliyamol.cn:8081/webdav/', 'webdav_hostname': 'https://pan.liliyamol.cn/webdav/',
'webdav_login': 'fan@yunying.com', 'webdav_login': 'fan@yunying.com',
'webdav_password': 'm%Bn$w5jgiNsNC', 'webdav_password': 'm%Bn$w5jgiNsNC',
'disable_check': True, 'disable_check': True,
} }
client = Client(options) client = Client(options)
tempPath = os.path.join(os.path.dirname(__file__), 'temp') tempPath = os.path.join(os.path.dirname(__file__), 'temp')
playlists = os.listdir(tempPath) playlists = os.listdir(tempPath)
try: try:
client.clean('Music/#playlist') client.clean('Music/#playlist')
except RemoteResourceNotFound as exception: except RemoteResourceNotFound as exception:
print('clean failed!') print('clean failed!')
except ResponseErrorCode as exception: except ResponseErrorCode as exception:
print('error') print('error')
for fileName in playlists: for fileName in playlists:
path = os.path.join(tempPath, fileName) path = os.path.join(tempPath, fileName)
try: try:
client.upload('Music/#playlist/' + fileName, path) client.upload('Music/#playlist/' + fileName, path)
print(fileName + ' upload success!!') print(fileName + ' upload success!!')
except LocalResourceNotFound as exception: except LocalResourceNotFound as exception:
print(fileName + ' upload failed!!') print(fileName + ' upload failed!!')