-
-
Notifications
You must be signed in to change notification settings - Fork 558
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
some fixes #165
some fixes #165
Conversation
Reviewer's Guide by SourceryThis pull request refactors the torrent search functionality by removing the API search method and focusing solely on plugin-based searches. It also includes changes to how thumbnails are handled and fixes some issues with archive extraction. Sequence diagram for simplified torrent search flowsequenceDiagram
actor User
participant Bot
participant QBittorrent
participant SearchPlugins
User->>Bot: Send search command with key
alt No search key provided
Bot-->>User: Request search key
else Search key provided
Bot->>Bot: Show plugin selection buttons
User->>Bot: Select search plugin
Bot->>QBittorrent: Initialize search with plugin
QBittorrent->>SearchPlugins: Execute search
SearchPlugins-->>QBittorrent: Return search results
QBittorrent-->>Bot: Return results
Bot->>Bot: Format results
Bot-->>User: Display formatted results
end
Class diagram showing search module structure changesclassDiagram
class SearchModule {
-PLUGINS: list
-TELEGRAPH_LIMIT: int
+initiate_search_tools()
+search(key, site, message)
+get_result(search_results, key, message)
+plugin_buttons(user_id)
}
class FFmpegStatus {
+STATUS_ETHUMB: str
+status()
+task()
}
SearchModule --> FFmpegStatus: uses
note for SearchModule "Removed API search functionality
Simplified to plugin-only searches"
Flow diagram for archive extraction processgraph TD
A[Start Extraction] --> B{Check Archive Type}
B -->|Split Archive| C[Extract First Part]
B -->|Single Archive| D[Extract File]
C --> E{Extraction Success?}
D --> E
E -->|Yes| F[Delete Original Archives]
E -->|No| G[Keep Original Files]
F --> H[Return Extracted Path]
G --> H
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @5hojib - I've reviewed your changes - here's some feedback:
Overall Comments:
- Please use a more descriptive commit message that explains what changes are being made. 'some fixes' does not provide enough context about the changes in this PR.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -46,6 +46,8 @@ def update_aria2_options(): | |||
|
|||
|
|||
async def load_settings(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Low code quality found in load_settings - 10% (low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
@@ -19,7 +19,8 @@ | |||
|
|||
async def error_check(message): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): We've found these issues:
- Move assignments closer to their usage (
move-assign
) - Low code quality found in error_check - 12% (
low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
@@ -1198,3 +1198,66 @@ async def proceed_watermark(self, dl_path, gid): | |||
if checked: | |||
cpu_eater_lock.release() | |||
return dl_path | |||
|
|||
async def proceed_embed_thumb(self, dl_path, gid): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Low code quality found in TaskConfig.proceed_embed_thumb - 16% (low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
@@ -94,11 +93,10 @@ async def _download(self, message, path): | |||
|
|||
async def add_download(self, message, path, session): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (code-quality): Low code quality found in TelegramDownloadHelper.add_download - 24% (low-code-quality
)
Explanation
The quality score for this function is below the quality threshold of 25%.This score is a combination of the method length, cognitive complexity and working memory.
How can you solve this?
It might be worth refactoring this function to make it shorter and more readable.
- Reduce the function length by extracting pieces of functionality out into
their own functions. This is the most important thing you can do - ideally a
function should be less than 10 lines. - Reduce nesting, perhaps by introducing guard clauses to return early.
- Ensure that variables are tightly scoped, so that code using related concepts
sits together within the function rather than being scattered.
# Fallback to environment variables for DATABASE_URL | ||
DATABASE_URL = ( | ||
config_file.get("DATABASE_URL", "").strip() | ||
or os.getenv("DATABASE_URL", "").strip() | ||
) | ||
DATABASE_URL = config_file.get("DATABASE_URL", "") or os.getenv("DATABASE_URL", "") | ||
|
||
if DATABASE_URL: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Use named expression to simplify assignment and conditional (use-named-expression
)
# Fallback to environment variables for DATABASE_URL | |
DATABASE_URL = ( | |
config_file.get("DATABASE_URL", "").strip() | |
or os.getenv("DATABASE_URL", "").strip() | |
) | |
DATABASE_URL = config_file.get("DATABASE_URL", "") or os.getenv("DATABASE_URL", "") | |
if DATABASE_URL: | |
if DATABASE_URL := config_file.get("DATABASE_URL", "") or os.getenv( | |
"DATABASE_URL", "" | |
): |
Summary by Sourcery
Refactor torrent search functionality to use qBittorrent search plugins, removing the dependency on an external search API. Update archive handling during extraction to delete split archive files after successful extraction. Embed thumbnails into video files using ffmpeg.
Bug Fixes:
Enhancements: