Changed win-style backslashes to unix-style forward slashes

This commit is contained in:
Maximilian Wagner
2023-08-05 18:20:04 +02:00
parent 7c234a72ba
commit 11697a56cc
4 changed files with 15 additions and 15 deletions

View File

@@ -276,12 +276,12 @@ def download_all(url, ext, parent=None):
True)[0]
# set the base relative path for playlists
relativePath = parent + '\\'
relativePath = parent + '/'
# does that subdirectory already exist?
if os.path.exists(f'downloads\\{parent}'):
if os.path.exists(f'downloads/{parent}'):
subdirs = []
for file in os.scandir(f'downloads\\{parent}'):
for file in os.scandir(f'downloads/{parent}'):
if file.is_dir():
subdirs.append(file)
@@ -294,24 +294,24 @@ def download_all(url, ext, parent=None):
# update previous parents directory
query_db_threaded('UPDATE playlist SET folder = :folder WHERE ROWID = :rowid',
{'folder': relativePath + str(parent_rowid) + '\\', 'rowid': parent_rowid})
{'folder': relativePath + str(parent_rowid) + '/', 'rowid': parent_rowid})
# update the folder entry in collection
query_db_threaded('UPDATE collection SET playlist = :folder WHERE playlist = :folder_old',
{'folder': relativePath + str(parent_rowid) + '\\', 'folder_old': relativePath})
{'folder': relativePath + str(parent_rowid) + '/', 'folder_old': relativePath})
# move all files into subdirectory 'downloads/parent/rowid'
srcpath = downloads_path() + parent + '\\'
dstpath = srcpath + str(parent_rowid) + '\\'
srcpath = downloads_path() + parent + '/'
dstpath = srcpath + str(parent_rowid) + '/'
for f in os.scandir(srcpath):
os.renames(srcpath + f.name, dstpath + f.name)
# adjust path in db table video
query_db_threaded('UPDATE video SET path = :new_path WHERE path = :old_path',
{'new_path': relativePath + str(parent_rowid) + '\\', 'old_path': relativePath})
{'new_path': relativePath + str(parent_rowid) + '/', 'old_path': relativePath})
# append relative path
relativePath += str(rowid_new) + '\\'
relativePath += str(rowid_new) + '/'
# set the relative path of playlist in recently added entry
update_playlist_folder_by_rowid(relativePath, rowid_new)

View File

@@ -44,12 +44,12 @@ def db_add_via_download(ext, parent_rowid=None, parent=None):
# if a parent was specified
else:
# set relative path
relative_path = parent + '\\'
relative_path = parent + '/'
# if a rowid was specified
if parent_rowid is not None:
# adjust the relative path
relative_path += str(parent_rowid) + '\\'
relative_path += str(parent_rowid) + '/'
# insert all new files into db
for i in range(len(titles)):
@@ -76,10 +76,10 @@ def add_new_video(video_id, name, ext, path):
def add_new_video_to_collection(parent, video_id):
exists = query_db_threaded('SELECT * FROM collection WHERE playlist = :folder AND video = :id',
{'folder': parent + '\\', 'id': video_id})
{'folder': parent + '/', 'id': video_id})
if not len(exists) > 0:
add_collection_entry(parent + '\\', video_id)
add_collection_entry(parent + '/', video_id)
return

View File

@@ -109,7 +109,7 @@ def download():
# this is flaky for whatever reason; might be because of special chars?
return send_from_directory(
'downloads\\' + path,
'downloads/' + path,
name + ext
)

View File

@@ -4,7 +4,7 @@ import os.path as path
# a way to get the 'parent_root/downloads' directory; alternative for nonexistent global immutable
# since app context does not exist where this is called, using app.config will not work
def downloads_path() -> str:
return path.dirname(path.abspath(__file__)) + '\\downloads\\'
return path.dirname(path.abspath(__file__)) + '/downloads/'
# dissects a given full path to a file into its components