'how to add back functionality in youtube converter without adding a menu in python

from os import link
from pytube import YouTube
import youtube_dl
soru = input("MP4 mü MP3 mü yüklemek istiyorsun?:  ")
while soru != 'DUR' or soru != 'dur':
    if soru == 'MP4' or soru == 'mp4' or soru == 'mP4' or soru == 'Mp4':
        link = input("İndirmek istediğin videonun linkini at:  ")
        print('Yükleniyor...')
        yt=YouTube(link)
        ys = yt.streams.get_highest_resolution()
        ys.download('mp4')
        print('Yüklendi.')
        soru = input("MP4 mü MP3 mü yüklemek istiyorsun?:  ")
    if soru == 'MP3' or soru == 'mp3' or soru == 'Mp3' or soru == 'mP3':
        link = input("İndirmek istediğin videonun linkini at:  ")
        print('Yükleniyor...')
        ydl_opts = {
        'format': 'bestaudio/best',
        'outtmpl': 'C:/Users/Ulas/Desktop/ytdownloadbot/mp3/%(title)s.%(ext)s',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
            }],
        }
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download([link])
            print('Yüklendi.')
            soru = input("MP4 mü MP3 mü yüklemek istiyorsun?:  ")
    else:
        if soru == 'DUR' or soru == 'dur':
            break
        print('MP3 veya MP4 yazmalısın!')
        soru = input("MP4 mü MP3 mü yüklemek istiyorsun?:  ")

This is the code, it first asks if you want to download an mp4 or mp3 file. After you answer, it jumps to the next input asking for a link.

That is the point where I want to add a back option, I want it to go back to the "mp4 or mp3?" question when I type in "back" to the URL question.

I'm very new to coding so even in a code as small as this I expect there are too many problems to talk about, but it's fairly simple code so I don't really care about making it more efficient. I used youtube_dl and pytube at the same time because I started the code with pytube and when I got to the mp3 conversion part I wasn't able to convert to mp3, so instead of writing the whole code from scratch I just used youtube_dl for mp3 files.

I looked for a solution but couldn't find it so here's my post, any way to add a way to go back to the first question without creating a menu for it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source