Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Code not working ('>' not supported between instances of 'NoneType' and 'int') #774

Open
@Fideier264

Description

@Fideier264

image

This is the issue that comes. Please can somebody help, saw the code here on github and thought it is cool and wanted to try it.

Full code: `import yt_dlp

def download_youtube_video(video_url):
"""Downloads a YouTube video using yt-dlp."""

ydl_opts = {
    "outtmpl": "%(title)s.%(ext)s",  # Output filename template
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
    info_dict = ydl.extract_info(video_url, download=False)
    formats = info_dict.get("formats", None)

    # Print all the available formats and ask the user to select
    for f in formats:
        print(f"{f['format_id']}:\t{f['ext']} ({f.get('format_note', None)}p)")

    resolution_choice = input(
        "Do you want to select from the available options? (y/n): "
    )

    if resolution_choice.lower() == "y":
        format_id = input("Enter the format id of the video: ")
        ydl_opts["format"] = format_id
    else:
        # Select the highest resolution format
        highest_resolution = max(formats, key = lambda x: x.get("height", 0))
        format_id = highest_resolution["format_id"]
        ydl_opts["format"] = format_id

    # Download the video
    ydl.download([video_url])
    print("Download complete using yt-dlp!")

if name == "main":
video_url = input("Enter the URL: ")
download_youtube_video(video_url)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions