Skip to content

Commit

Permalink
fix: natively creating twitch dir
Browse files Browse the repository at this point in the history
  • Loading branch information
biodrone committed Jan 28, 2022
1 parent 90f6208 commit 5de7a24
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions streamdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,18 +325,12 @@ def twitch_download(url, user, outdir):
f"{outdir.rsplit('/', 1)[0]}/{url.upper().split('.')[0]}/{user}/{user} - {datetime.utcnow().date()}.mp4"
)
# create dir because streamlink is incapable of doing so apparently
# TODO: Do this natively
subprocess.call(
[
"mkdir",
"-p",
"{}/{}/{}".format(
outdir.rsplit("/", 1)[0], url.upper().split(".")[0], user
),
]
)
# download video with streamlink
(ffmpeg.input(stream["best"].url).output("test.mp4").run())
p = Path(f"{outdir.rsplit('/', 1)[0]}/{url.upper().split('.')[0]}/{user}")
p.mkdir(parents=True, exist_ok=True)

# download video with ffmpeg
timestamp = str(datetime.utcnow()).replace(" ", "_").replace(":", "-")
ffmpeg.input(stream["best"].url).output(f"{p}/{user}-{timestamp}.mp4").run()
return True
except NoPluginError:
logger.warning("Streamlink is unable to handle the URL '{0}'".format(url))
Expand Down

0 comments on commit 5de7a24

Please sign in to comment.