This commit is contained in:
zuckerberg 2021-09-24 17:52:26 -04:00
parent 209e5e2292
commit 96f6572a4b
2 changed files with 14 additions and 10 deletions

View File

@ -4,5 +4,5 @@ pkgs.python3Packages.buildPythonApplication {
pname = "radio"; pname = "radio";
src = self; src = self;
version = "0.1"; 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 ];
} }

View File

@ -87,6 +87,7 @@ fuseTorrentLocation = "torrent"
btfsDataLocation = "btfs-data" btfsDataLocation = "btfs-data"
def mountTorrent(magnet): def mountTorrent(magnet):
print("mounting torrent...")
umountTorrent() umountTorrent()
os.mkdir(fuseTorrentLocation) os.mkdir(fuseTorrentLocation)
o = subprocess.Popen([ o = subprocess.Popen([
@ -99,18 +100,21 @@ def mountTorrent(magnet):
o.communicate() # wait for it to finish o.communicate() # wait for it to finish
def umountTorrent(): def umountTorrent():
if os.path.isdir(fuseTorrentLocation): print("mock unmounting torrent...")
o = subprocess.Popen([ # if os.path.isdir(fuseTorrentLocation):
"fusermount", # o = subprocess.Popen([
"-u", fuseTorrentLocation # "fusermount",
]) # "-u", fuseTorrentLocation
o.communicate() # wait for it to finish # ])
os.rmdir(fuseTorrentLocation) # o.communicate() # wait for it to finish
if os.path.isdir(btfsDataLocation): # os.rmdir(fuseTorrentLocation)
shutil.rmtree(btfsDataLocation) # if os.path.isdir(btfsDataLocation):
# shutil.rmtree(btfsDataLocation)
def getTorrentMedia(): def getTorrentMedia():
print("Getting torrent media...")
files = glob.glob(fuseTorrentLocation + '/**/*', recursive=True) 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")] 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: if len(files) == 0:
return None return None