diff --git a/default.nix b/default.nix index 1ee0035..5b1db5f 100644 --- a/default.nix +++ b/default.nix @@ -4,5 +4,5 @@ pkgs.python3Packages.buildPythonApplication { pname = "radio"; src = self; version = "0.1"; - propagatedBuildInputs = with pkgs.python3Packages; [ pip ffmpeg-python flask requests pkgs.ffmpeg pkgs.btfs ]; + propagatedBuildInputs = with pkgs.python3Packages; [ pip ffmpeg-python flask requests pkgs.ffmpeg pkgs.btfs pkgs.fuse ]; } diff --git a/downloader.py b/downloader.py index 63b0a1a..890787b 100644 --- a/downloader.py +++ b/downloader.py @@ -87,6 +87,7 @@ fuseTorrentLocation = "torrent" btfsDataLocation = "btfs-data" def mountTorrent(magnet): + print("mounting torrent...") umountTorrent() os.mkdir(fuseTorrentLocation) o = subprocess.Popen([ @@ -99,18 +100,21 @@ def mountTorrent(magnet): o.communicate() # wait for it to finish def umountTorrent(): - if os.path.isdir(fuseTorrentLocation): - o = subprocess.Popen([ - "fusermount", - "-u", fuseTorrentLocation - ]) - o.communicate() # wait for it to finish - os.rmdir(fuseTorrentLocation) - if os.path.isdir(btfsDataLocation): - shutil.rmtree(btfsDataLocation) + print("mock unmounting torrent...") + # if os.path.isdir(fuseTorrentLocation): + # o = subprocess.Popen([ + # "fusermount", + # "-u", fuseTorrentLocation + # ]) + # o.communicate() # wait for it to finish + # os.rmdir(fuseTorrentLocation) + # if os.path.isdir(btfsDataLocation): + # shutil.rmtree(btfsDataLocation) def getTorrentMedia(): + print("Getting torrent media...") files = glob.glob(fuseTorrentLocation + '/**/*', recursive=True) + print(files) files = [f for f in files if f.endswith(".acc") or f.endswith(".avi") or f.endswith(".mid") or f.endswith(".midi") or f.endswith(".mp3") or f.endswith(".mp4") or f.endswith(".mpeg") or f.endswith(".oga") or f.endswith(".ogv") or f.endswith(".opus") or f.endswith(".ts") or f.endswith(".wav") or f.endswith(".weba") or f.endswith(".webm") or f.endswith(".3gp") or f.endswith(".3g2")] if len(files) == 0: return None