Skip to content

Libs version update. Remove @username from video link #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2025
Merged

Conversation

ovchynnikov
Copy link
Owner

@ovchynnikov ovchynnikov commented Apr 20, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved URL cleaning to better handle markdown formatting and remove usernames from extracted URLs.
  • Chores

    • Updated Python dependencies to the latest versions for improved stability and compatibility.

@ovchynnikov ovchynnikov self-assigned this Apr 20, 2025
Copy link
Contributor

coderabbitai bot commented Apr 20, 2025

Walkthrough

The changes update the clean_url function in src/main.py to more thoroughly sanitize input URLs by removing markdown formatting and usernames, ensuring a cleaner extraction of URLs from message text. Additionally, the requirements.txt file is updated to specify newer versions for three dependencies: python-dotenv, yt-dlp, and gallery-dl. No other files or public interfaces are modified.

Changes

File(s) Change Summary
src/main.py Enhanced the clean_url function to always remove markdown formatting, extract the first URL segment, and strip usernames.
src/requirements.txt Updated dependency versions: python-dotenv to 1.1.0, yt-dlp to 2025.3.31, gallery-dl to 1.29.4.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MainPy

    User->>MainPy: Send message with potential markdown and username
    MainPy->>MainPy: clean_url(message_text)
    Note right of MainPy: Remove all '**', split by space, take first segment, remove username after '@'
    MainPy-->>User: Return cleaned URL
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ovchynnikov ovchynnikov merged commit b42f098 into main Apr 20, 2025
3 of 4 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main.py (1)

121-121: Consider using regular expressions for more robust markdown cleaning.

While the current implementation works for basic "**" removal, it might miss other markdown formatting. Consider using a regex approach if you need to handle more complex markdown in the future.

-url = message_text.replace("**", "")
+# Remove various markdown formatting like **, *, __, etc.
+url = re.sub(r'[\*_]{1,2}', '', message_text)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9055c33 and 3070d74.

📒 Files selected for processing (2)
  • src/main.py (1 hunks)
  • src/requirements.txt (1 hunks)
🔇 Additional comments (4)
src/requirements.txt (1)

2-4: Version updates look good.

The dependencies have been updated to newer versions:

  • python-dotenv: 1.0.1 -> 1.1.0
  • yt-dlp: 2025.3.25 -> 2025.3.31
  • gallery-dl: 1.29.2 -> 1.29.4

These are minor version updates that should maintain backward compatibility while providing bug fixes and new features.

src/main.py (3)

112-112: Docstring updated appropriately.

The function docstring has been correctly updated to reflect the new capability of removing usernames from URLs.


120-129: Enhanced URL cleaning implementation looks good.

The improved clean_url function now:

  1. Removes all occurrences of markdown formatting ("**")
  2. Extracts only the first space-separated segment as the URL
  3. Removes any username by splitting on '@' and taking the first part

This implementation is more robust than before and successfully addresses the PR objective to remove usernames from video links.


127-127:

❓ Verification inconclusive

Edge case: Handle URLs with multiple @ symbols.

The current implementation only handles a single '@' symbol by taking everything before the first occurrence. This is fine for most cases but could potentially truncate valid URLs that contain '@' as part of their structure (e.g., some API URLs).

Consider if this is an issue for your use case. If you need to specifically target only usernames at the end of URLs, you might want to use a more targeted approach:


🏁 Script executed:

#!/bin/bash
# Check if there are any examples in the codebase of URLs with @ symbols that are not usernames
rg -i "https?://[^@]+@" --no-filename

Length of output: 39


Review: Potential over‑trimming of URLs with “@”

The current code

url = url.split('@')[0]

will truncate everything after the first @, which can mistakenly remove valid parts of a URL if it contains multiple @ symbols (for example in user:pass@host@domain). We ran a quick search for hard‑coded URLs with @ in the repo:

rg -i 'https?://[^@]+@'

No matches were found. Please manually verify whether any configuration files, test fixtures, or runtime inputs include URLs with embedded @ characters that should be preserved. If so, consider one of the following approaches:

  • Use Python’s urllib.parse.urlparse to strip only the user‑info segment (i.e., ParseResult.username/.password), leaving the rest of the URL intact.
  • Apply a more targeted regex, for example:
    import re
    m = re.match(r'^(https?://)(?:[^@/]+@)?(.+)$', url)
    url = m.group(1) + m.group(2) if m else url

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.

1 participant