Added cleaned up path (#6 fix) (#42)

* Added cleaned up path (#6 fix)

* autopep8 action fixes (#43)
This commit is contained in:
Peter Taylor 2022-03-27 00:09:23 +00:00 committed by GitHub
parent 9370bbfe46
commit 0bebcddcc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -53,7 +53,8 @@ class Game:
continue
file = d['filename'] or d['display_name'] or d['id']
path = f"{self.publisher_slug}/{self.game_slug}"
path = itchiodl.utils.clean_path(
f"{self.publisher_slug}/{self.game_slug}")
if os.path.exists(f"{path}/{file}"):
print(f"Skipping {path}/{file}")
continue

View file

@ -1,6 +1,7 @@
import requests
import re
import os
import sys
from clint.textui import progress
@ -54,3 +55,11 @@ def download(url, path, name, file):
print(f"Downloaded {filename}")
return f"{path}/{filename}", True
def clean_path(path):
"""Cleans a path on windows"""
if sys.platform in ["win32", "cygwin", "msys"]:
path_clean = re.replace(r'[\<\>\:\"\/\\\|\?\*]', "-", path)
return path_clean
return path