Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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

Copy link
Copy link
@Fideier264

Description

@Fideier264
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.