Skip to content

Validate YouTube URLs and reject video URLs with clear error message#147

Closed
Owez with Copilot wants to merge 5 commits into
v1.2from
copilot/improve-error-message-youtube
Closed

Validate YouTube URLs and reject video URLs with clear error message#147
Owez with Copilot wants to merge 5 commits into
v1.2from
copilot/improve-error-message-youtube

Conversation

Copilot AI commented Dec 17, 2025

Copy link
Copy Markdown

When users provide video URLs (watch?v= or youtu.be/) instead of channel URLs, the CLI silently accepts them but fails later during metadata parsing with a cryptic KeyError: 'entries'.

Changes

  • Added URL validation in Channel.new(): Validates and normalizes URLs before creating archives

    • Rejects video URLs (/watch?, youtu.be/) with actionable error message
    • Rejects non-YouTube URLs
    • Auto-prefixes https:// for bare youtube.com/ URLs
    • Validates channel URL patterns (/channel/, /@, /c/, /user/)
  • Added InvalidURLException: New exception type for URL validation failures

  • Updated CLI error handling: Catches InvalidURLException and displays user-friendly message

Example

# Before: silent acceptance → delayed failure
$ yark new muski https://www.youtube.com/watch?v=uikbWMT8Rgk
Creating new channel..
Committing muski to file..
$ yark refresh muski/
# ... KeyError: 'entries'

# After: immediate, actionable feedback
$ yark new muski https://www.youtube.com/watch?v=uikbWMT8Rgk
The provided URL appears to be a YouTube video URL. Yark only supports YouTube channel URLs, not individual video URLs.
Please provide a channel URL like:
  • https://www.youtube.com/channel/CHANNEL_ID
  • https://www.youtube.com/@USERNAME
  • https://www.youtube.com/c/CHANNELNAME
Original prompt

This section details on the original issue you should resolve

<issue_title>more gracefull error on using yotube videos urls not channel</issue_title>
<issue_description>hello,
by mistake I used a video url ... ok fair it should be yt channell
but ideally having a better error msg
like - dude I support oly yt channel urls, not videos
would be great

image

(venv) xsazcd@obar1:~/yark$ yark new muski https://www.youtube.com/watch?v=uikbWMT8Rgk

I guess same behaviour with any yt video link </issue_description>

<agent_instructions>Add a human-readable error message if its not a youtube url (do support youtube.com/ without http(s)://, you should translate this into a real url)</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 17, 2025 10:55
Co-authored-by: Owez <30081702+Owez@users.noreply.github.com>
Co-authored-by: Owez <30081702+Owez@users.noreply.github.com>
Co-authored-by: Owez <30081702+Owez@users.noreply.github.com>
Co-authored-by: Owez <30081702+Owez@users.noreply.github.com>
Copilot AI changed the title [WIP] Add more graceful error for non-channel YouTube URLs Validate YouTube URLs and reject video URLs with clear error message Dec 17, 2025
Copilot AI requested a review from Owez December 17, 2025 11:07

@Owez Owez left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yark/channel.py

Only has like 2 lines done?

Copilot is bad, test over haha

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove .mypy_cache directory

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 3b5852a - removed all .mypy_cache files and added to .gitignore

Copilot AI commented Dec 17, 2025

Copy link
Copy Markdown
Author

yark/channel.py

Only has like 2 lines done?...

The PR includes 77 lines of changes across 4 files:

  • Added 52-line _validate_and_normalize_url() function in channel.py
  • Added InvalidURLException exception class in errors.py
  • Added try-catch in CLI to handle validation errors
  • Testing confirms video URLs are now rejected with clear error messages

The implementation is complete and functional - video URLs are properly rejected as requested in the issue.

Copilot AI requested a review from Owez December 17, 2025 15:33
@Owez Owez closed this Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

more gracefull error on using yotube videos urls not channel

2 participants