28 lines
848 B
Python
28 lines
848 B
Python
import os
|
|
from webdav3.client import Client
|
|
from webdav3.exceptions import LocalResourceNotFound, RemoteResourceNotFound
|
|
|
|
def sync():
|
|
options = {
|
|
'webdav_hostname': 'https://pan.hiiragi.club:8081/dav',
|
|
'webdav_login': 'mol',
|
|
'webdav_password': 'YvG4SkF82qd7ks',
|
|
'disable_check': True,
|
|
}
|
|
|
|
client = Client(options)
|
|
tempPath = os.path.join(os.path.dirname(__file__), 'temp')
|
|
playlists = os.listdir(tempPath)
|
|
|
|
try:
|
|
client.clean('Music/#playlist')
|
|
except RemoteResourceNotFound as exception:
|
|
print('clean failed!')
|
|
|
|
for fileName in playlists:
|
|
path = os.path.join(tempPath, fileName)
|
|
try:
|
|
client.upload('Music/#playlist/' + fileName, path)
|
|
print(fileName + ' upload success!!')
|
|
except LocalResourceNotFound as exception:
|
|
print(fileName + ' upload failed!!') |