Search code examples
pythondirectoryyoutubediscord.pyyoutube-dl

youtube_dl outtmpl format for linux


 queue_path = os.path.abspath(os.path.realpath("Queue") + f"\song{q_num}.%(ext)s")

                ydl_opts = {
                    'format': 'bestaudio/best',
                    'quiet': True,
                    'outtmpl': queue_path,
                    'postprocessors': [{
                    'key': 'FFmpegExtractAudio',
                    'preferredcodec': 'mp3',
                    'preferredquality': '192',
                }],
            }

                with youtube_dl.YoutubeDL(ydl_opts) as ydl:
                    print("Downloading audio now\n")
                    ydl.download([carmelSongs[query]])

This code works as expected on a windows machine, but the file doesn't go to the queue folder in the working directory in a linux machine(cloud hosting with heroku). This is a discord.py bot, and a lot of this code is from a youtube video that I watched where I adapted the code to fit to my needs. This is one of the parts of his code that I don't fully understand, so any help would be much appreciated!

I had a testing mechanism which didn't return anything:

@client.command()
async def troubleshoot(ctx):
    for item in os.listdir("Queue"):
        print(item)

Again, any help would be very much appreciated. I'm very much sure that this is the main issue, as all other aspects work perfectly.


Solution

  • Thanks to @peeol I was able to change all of the backslashes in my script to forwards slashes as per linux standard.