diff --git a/funcs/other/bedreNetflix.py b/funcs/other/bedreNetflix.py index df352a6..f78b712 100644 --- a/funcs/other/bedreNetflix.py +++ b/funcs/other/bedreNetflix.py @@ -1,4 +1,4 @@ -import requests, imdb, discord, json, math, time, asyncio, os +import requests, imdb, discord, json, math, time, asyncio, os, concurrent.futures from funcs import logThis radarrURL = "http://localhost:7878/api/v3/" @@ -7,11 +7,7 @@ qbittorrentURL = "http://localhost:1340/api/v2/" moviePath = "/media/plex/Server/movies/" showPath = "/media/plex/Server/Shows/" -async def fileSize(fp): - print(fp[:60],end="\r") - return os.path.getsize(fp) - -async def getSize(startPath,pathLength): +def getSize(startPath,pathLength): logThis("Getting the size of "+startPath) totalSize = 0 for dirpath, dirnames, filenames in os.walk(startPath): @@ -19,10 +15,12 @@ async def getSize(startPath,pathLength): fp = os.path.join(dirpath, f) # skip if it is symbolic link if not os.path.islink(fp): - totalSize += await fileSize(fp) + print(fp[:60],end="\r") + totalSize += os.path.getsize(fp) return totalSize + async def formatSize(size): if size >= 1024**4: return ("%.1f" % (size/(1024**4))) + "TB" @@ -289,7 +287,9 @@ class BedreNetflix(): if os.path.isfile(fp): size = os.path.getsize(fp) else: - size = await getSize(fp,pathLength) + with concurrent.futures.ThreadPoolExecutor() as executor: + future = executor.submit(getSize,fp,pathLength) + size = future.result() directories.append((str(f),size)) directories.sort(key=lambda tup: tup[1]) directories.reverse()