Skip to content
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

TorBox Integration #132

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

anonymous-org-za
Copy link

@anonymous-org-za anonymous-org-za commented Aug 15, 2024

Adds support for TorBox in DMM!

Please make sure to go through and check things are correct. There was testing done, but we might have missed something small. We are also not sure about hash list support as it looks like it is on a different site.

We also changed some things in the Readme regarding TorBox support, and also changed the Database used (previously PlanetScale) and also changed the Proxy used (previously proxyme.org).

Note: there were some issues with rendering on /hashlist, maybe it is because there was no way to really locally test, but do some testing on that page specifically.

Further concerning hashlists, it seems as though the hashlist site has code elsewhere, with RD and AD specific code that will need to be modified.

Summary by CodeRabbit

  • New Features

    • Introduced support for the TorBox service, allowing users to manage torrents effectively.
    • Added a new login page for TorBox, enhancing user authentication options.
    • Integrated functionalities for adding and deleting torrents from the TorBox library.
  • Improvements

    • Updated documentation to provide clearer setup instructions and service descriptions.
    • Enhanced user feedback mechanisms with toast notifications for actions related to TorBox.
  • Bug Fixes

    • Addressed issues with API path construction in various components, ensuring proper request handling across services.
  • Style

    • Improved UI layouts for a more responsive and visually appealing experience.

Copy link

coderabbitai bot commented Aug 15, 2024

Warning

Rate limit exceeded

@anonymous-org-za has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 43 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between d72d5e9 and 1a52d78.

Walkthrough

The recent changes enhance the media library management system by integrating the TorBox service. This addition improves user authentication, torrent management, and API interactions. Notable updates include the expansion of the user interface to support TorBox, modifications to existing components for better state management, and the introduction of new utilities for handling torrents specifically from TorBox. Overall, these updates significantly enhance functionality and user experience.

Changes

Files Change Summary
README.md, next.config.js Expanded service descriptions to include TorBox; updated setup instructions and API hostname references.
src/hooks/auth.ts Added support for TorBox user management, including new hooks and interfaces for authentication.
src/pages/anime/[animeid].tsx, ... Integrated TorBox into the MovieSearch component with new state and functions for torrent management.
src/pages/...search.tsx, ...browse/... Commented out conditional logic for API path encoding, simplifying endpoint construction.
src/pages/hashlist.tsx, library.tsx Enhanced user torrent management functionalities to support TorBox, including new functions and states.
src/services/torbox.ts, mediasearch.ts Introduced new service functions for interacting with the TorBox API and updated data structures to include tbAvailable.
src/utils/... Added multiple utility functions for torrent handling specific to TorBox, including adding and deleting torrents.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant TorBoxAPI

    User->>App: Requests to add torrent
    App->>TorBoxAPI: send add torrent request
    TorBoxAPI-->>App: Returns success/failure
    App-->>User: Notify user of success/failure
Loading
sequenceDiagram
    participant User
    participant App
    participant AuthService

    User->>App: Initiates login
    App->>AuthService: Check login with TorBox
    AuthService-->>App: Return user info
    App-->>User: Display user dashboard
Loading

🐰 In fields of green, I hop with glee,
New changes sprout like leaves on a tree.
TorBox joins the fun, a friend so dear,
With torrents galore, let’s give a cheer!
A world of films, we now can explore,
Hopping through data, who could ask for more? 🌿✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@Wamy-Dev
Copy link

Handles #109

Copy link

@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: 12

Outside diff range, codebase verification and nitpick comments (7)
src/pages/torbox/login.tsx (1)

37-40: Enhance error handling for API key submission.

Consider providing user feedback after setting the API key, such as redirecting or showing a success message.

+  if (!regexTest) {
+      setError("Not a valid TorBox API key.");
+  } else {
+      setApiKey(submittedApiKey);
+      // Consider showing a success message or redirecting
+  }
src/services/torbox.ts (1)

87-103: Consider adding a success message in deleteTorBoxTorrent.

Currently, the function only logs errors. Consider logging a success message for confirmation when a torrent is deleted.

console.log(`Successfully deleted torrent with ID: ${id}`);
README.md (3)

9-9: Remove the comma before 'because'.

The clause is essential to the meaning, so the comma is unnecessary.

- without worrying about storage limits, because the files are shared among all users.
+ without worrying about storage limits because the files are shared among all users.
Tools
LanguageTool

[formatting] ~9-~9: If the ‘because’ clause is essential to the meaning, do not use a comma before the clause.
Context: ...nt without worrying about storage limits, because the files are shared among all users. Y...

(COMMA_BEFORE_BECAUSE)


19-19: Use a more formal term than 'amazing'.

Consider using 'exceptional' or 'outstanding' for a more formal tone.

- the amazing service
+ the exceptional service
Tools
LanguageTool

[style] ~19-~19: Consider using a more formal and expressive alternative to ‘amazing’.
Context: ... ## Features This builds on top of the amazing service brought by [Real-Debrid](http:/...

(AWESOME)


47-47: Clarify the External Search API setup.

Ensure the instructions clearly explain the purpose of changing EXTERNAL_SEARCH_API_HOSTNAME.

- If you don't want to build your own library, edit the config
+ To use an external search API instead of building your own library, edit the config
src/utils/addMagnet.ts (1)

161-163: Clarify the purpose of handleRestartTorBoxTorrent.

Consider adding a comment explaining why the function only displays a toast and does not perform any operations.

// TorBox does not support restarting torrents, hence only a notification is provided.
src/pages/index.tsx (1)

30-32: Refine the error message for tbError.

Consider providing a more detailed error message to help users troubleshoot issues with TorBox integration.

- 'TorBox get user info failed, try clearing DMM site data and login again'
+ 'Failed to retrieve TorBox user information. Please clear your DMM site data and try logging in again.'
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4ccbb64 and d72d5e9.

Files selected for processing (24)
  • README.md (4 hunks)
  • next.config.js (2 hunks)
  • src/hooks/auth.ts (7 hunks)
  • src/pages/anime/[animeid].tsx (8 hunks)
  • src/pages/animesearch.tsx (2 hunks)
  • src/pages/browse/anime.tsx (1 hunks)
  • src/pages/browse/recent.tsx (1 hunks)
  • src/pages/hashlist.tsx (18 hunks)
  • src/pages/index.tsx (5 hunks)
  • src/pages/library.tsx (20 hunks)
  • src/pages/movie/[imdbid].tsx (10 hunks)
  • src/pages/search.tsx (2 hunks)
  • src/pages/show/[imdbid]/[seasonNum].tsx (9 hunks)
  • src/pages/start.tsx (2 hunks)
  • src/pages/torbox/login.tsx (1 hunks)
  • src/services/mediasearch.ts (2 hunks)
  • src/services/torbox.ts (1 hunks)
  • src/torrent/userTorrent.ts (1 hunks)
  • src/utils/addMagnet.ts (3 hunks)
  • src/utils/deleteTorrent.ts (2 hunks)
  • src/utils/fetchTorrents.ts (3 hunks)
  • src/utils/instantChecks.ts (3 hunks)
  • src/utils/showInfo.ts (2 hunks)
  • src/utils/withAuth.tsx (3 hunks)
Additional context used
LanguageTool
README.md

[formatting] ~9-~9: If the ‘because’ clause is essential to the meaning, do not use a comma before the clause.
Context: ...nt without worrying about storage limits, because the files are shared among all users. Y...

(COMMA_BEFORE_BECAUSE)


[style] ~19-~19: Consider using a more formal and expressive alternative to ‘amazing’.
Context: ... ## Features This builds on top of the amazing service brought by [Real-Debrid](http:/...

(AWESOME)

Additional comments not posted (45)
src/utils/deleteTorrent.ts (1)

35-47: LGTM! The function handleDeleteTbTorrent is well-implemented.

The addition of handleDeleteTbTorrent follows the existing pattern for handling torrent deletions and maintains consistency in error handling and notifications.

src/utils/withAuth.tsx (1)

1-1: LGTM! The authentication logic is enhanced to include TorBox support.

The integration of useTorBoxApiKey and updates to the authentication logic ensure that the application handles the TorBox API key correctly. The changes maintain consistency with existing logic.

Also applies to: 15-15, 21-21, 30-30

src/services/mediasearch.ts (1)

21-21: LGTM! But verify the usage of tbAvailable.

The addition of tbAvailable to SearchResult and EnrichedHashlistTorrent looks good and maintains backward compatibility.

Ensure that the new tbAvailable property is correctly utilized and handled across the codebase.

Also applies to: 43-43

Verification successful

tbAvailable Property Usage Verified

The tbAvailable property is actively used in the codebase, specifically in src/utils/instantChecks.ts, where it is set to true or false. This confirms that the property is integrated into the application's logic. No further issues were found regarding its usage.

  • Files Involved:
    • src/utils/instantChecks.ts: Modifies tbAvailable.
    • src/services/mediasearch.ts: Defines tbAvailable.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the `tbAvailable` property in the codebase.

# Test: Search for the usage of `tbAvailable`. Expect: Occurrences where it is being used or checked.
rg --type typescript 'tbAvailable'

Length of output: 69


Script:

#!/bin/bash
# Description: Verify the usage of the `tbAvailable` property in the codebase.

# Test: Search for the usage of `tbAvailable`. Expect: Occurrences where it is being used or checked.
rg --glob '*.ts' 'tbAvailable'

Length of output: 378

next.config.js (1)

49-54: LGTM! But verify the usage of new configurations.

The addition of a new media source and the TorBox API endpoint in the configuration looks good.

Ensure that the new media source and the torboxHostname are correctly utilized in the application.

Also applies to: 71-71

src/pages/browse/anime.tsx (1)

19-21: Verify the impact of commenting out path encoding.

Commenting out the encoding logic for path may affect URL formatting. Ensure that this change does not introduce issues with API requests.

src/pages/browse/recent.tsx (1)

19-21: Verify the impact of disabling path encoding.

The conditional logic for encoding the path has been commented out. Ensure that the API endpoint can handle special characters in paths without encoding.

src/pages/torbox/login.tsx (1)

32-34: Ensure regex pattern covers all valid API key formats.

The regex pattern used for API key validation seems correct, but ensure it matches all valid formats for TorBox API keys.

Verification successful

Regex pattern appears to be correct for UUID format.

The regex pattern used in src/pages/torbox/login.tsx matches the standard UUID format, which is commonly used for API keys. Ensure this format is consistent with all valid TorBox API key formats. If TorBox uses a different or additional format, the regex will need to be updated accordingly.

  • File: src/pages/torbox/login.tsx
  • Lines: 32-34
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the regex pattern for API key validation.

# Test: Check if the regex pattern is consistent with TorBox API key format.
rg --type javascript -A 5 $'const apiKeyRegex' | grep 'apiKeyRegex'

Length of output: 101


Script:

#!/bin/bash
# Description: Verify the regex pattern for API key validation.

# Test: Check for occurrences of the apiKeyRegex pattern in the codebase.
rg 'const apiKeyRegex' -A 5

Length of output: 502

src/pages/start.tsx (1)

81-97: Verify loginWithTorBox implementation.

Ensure that the loginWithTorBox function is implemented correctly in the useDebridLogin hook.

Verification successful

loginWithTorBox is implemented and used correctly.

The function loginWithTorBox is defined in src/hooks/auth.ts and is correctly used in src/pages/start.tsx. It is part of the useDebridLogin hook's return value, confirming its integration.

  • src/hooks/auth.ts: Definition of loginWithTorBox.
  • src/pages/start.tsx: Usage of loginWithTorBox.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `loginWithTorBox` in the `useDebridLogin` hook.

# Test: Search for the `loginWithTorBox` function in the `useDebridLogin` hook.
ast-grep --lang javascript --pattern $'function useDebridLogin() {
  $$$
  function loginWithTorBox($_) {
    $$$
  }
  $$$  
}'

Length of output: 129


Script:

#!/bin/bash
# Description: Search for the `loginWithTorBox` function across the entire codebase.

# Test: Search for the `loginWithTorBox` function definition.
ast-grep --lang javascript --pattern 'function loginWithTorBox($_) {
  $$$
}'

Length of output: 79


Script:

#!/bin/bash
# Description: Search for references to `loginWithTorBox` across the entire codebase.

# Test: Search for any usage or import of `loginWithTorBox`.
rg 'loginWithTorBox'

Length of output: 274

src/hooks/auth.ts (4)

34-48: Interface TorBoxUser looks good.

The interface is well-structured and includes relevant user attributes for TorBox.


61-63: Function loginWithTorBox is correctly implemented.

The function correctly navigates to the TorBox login page using the router.


109-112: Function useTorBoxApiKey is correctly implemented.

The function successfully retrieves the TorBox API key from local storage.


122-132: Integration of TorBox in useCurrentUser is well-implemented.

The hook now correctly manages state for TorBox user data and error handling.

Ensure that the getTorBoxUser function is correctly implemented and handles errors properly.

Verification successful

Let's perform a broader search for getTorBoxUser to identify its definition or usage in the codebase.


The getTorBoxUser function is correctly implemented and integrated.

  • The function is defined in src/services/torbox.ts and includes proper API interaction and error handling.
  • It is correctly used in src/hooks/auth.ts to fetch and manage TorBox user data.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `getTorBoxUser`.

# Test: Search for the function implementation. Expect: Correct error handling and API interaction.
ast-grep --lang typescript --pattern $'function getTorBoxUser($_) {
  $$$
}'

Length of output: 77


Script:

#!/bin/bash
# Description: Broad search for `getTorBoxUser` to find its definition or usage.
rg 'getTorBoxUser' -A 3

Length of output: 817

src/pages/animesearch.tsx (2)

51-53: Verify the impact of commenting out path encoding in fetchMiscData.

Commenting out the encoding logic may affect how API requests are constructed. Ensure this change is intentional and doesn't disrupt functionality.


70-72: Verify the impact of commenting out path encoding in fetchData.

Commenting out the encoding logic may affect how API requests are constructed. Ensure this change is intentional and doesn't disrupt functionality.

src/pages/search.tsx (2)

52-54: Verify the impact of commenting out path encoding in fetchMiscData.

Commenting out the encoding logic may affect how API requests are constructed. Ensure this change is intentional and doesn't disrupt functionality.


72-74: Verify the impact of commenting out path encoding in fetchData.

Commenting out the encoding logic may affect how API requests are constructed. Ensure this change is intentional and doesn't disrupt functionality.

Verification successful

Commenting out path encoding in fetchData is likely intentional and non-disruptive.

The decodedQuery is already decoded using decodeURIComponent before being passed to fetchData, making the previous encoding step redundant.

  • src/pages/search.tsx: decodedQuery is derived from searchQuery using decodeURIComponent.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the commented encoding logic affects API requests.

# Test: Search for the usage of `fetchData`. Expect: No issues with API requests.
rg --type tsx 'fetchData'

Length of output: 53


Script:

#!/bin/bash
# Description: Verify if the commented encoding logic affects API requests.

# Test: Search for the usage of `fetchData` in all files.
rg 'fetchData'

Length of output: 1122


Script:

#!/bin/bash
# Description: Search for the definition and usage of `decodedQuery` in `src/pages/search.tsx`.

# Search for `decodedQuery` in `src/pages/search.tsx`.
rg 'decodedQuery' src/pages/search.tsx

Length of output: 221

src/pages/index.tsx (1)

122-139: LGTM! Rendering logic for tbUser is consistent.

The conditional rendering of tbUser information is consistent with other user types and enhances user experience.

src/utils/instantChecks.ts (1)

408-475: LGTM!

The function instantHashListCheckInTb is well-implemented and correctly integrates the instant property check.

src/pages/anime/[animeid].tsx (3)

1-11: Imports look good!

The new imports for TorBox integration are correctly added and align with the new functionality.


66-66: State management for TorBox is correctly implemented.

The tbKey state variable is correctly initialized and used in the component.


521-542: UI enhancements for TorBox are well-integrated.

The new buttons for TorBox operations are conditionally rendered and consistent with existing UI patterns.

src/pages/movie/[imdbid].tsx (3)

2-12: Imports look good!

The new imports for TorBox integration are correctly added and align with the new functionality.


67-67: State management for TorBox is correctly implemented.

The tbKey state variable is correctly initialized and used in the component.


525-542: UI enhancements for TorBox are well-integrated.

The new buttons for TorBox operations are conditionally rendered and consistent with existing UI patterns.

src/pages/hashlist.tsx (6)

Line range hint 1-42:
Imports and State Management Look Good!

The imports for TorBox integration and the state variable isClient are correctly added to support the new functionality.


94-94: TorBox Integration in fetchUserTorrentsList is Well-Implemented!

The addition of TorBox support is consistent with the existing pattern for Real-Debrid and AllDebrid.


287-302: downloadNonDupeTorrentsInTb Function is Consistent and Correct!

The function aligns with the established pattern for downloading torrents from other services, ensuring consistency.


324-330: addTb Function is Implemented Correctly!

The function uses the correct utility functions and updates the database appropriately for TorBox.


360-372: deleteTb Function is Implemented Correctly!

The function follows the correct pattern for deleting torrents and updating the state for TorBox.


Line range hint 445-647:
Button Rendering Logic for TorBox is Correctly Integrated!

The conditional rendering ensures that the UI reflects the availability of the TorBox service, maintaining consistency with other services.

src/pages/show/[imdbid]/[seasonNum].tsx (5)

Line range hint 2-70:
Imports and State Management Look Good!

The imports for TorBox integration and the state variable tbKey are correctly added to support the new functionality.


Line range hint 118-176:
Filtering Logic for TorBox is Well-Integrated!

The addition of tbAvailable is consistent with the existing logic for other services, ensuring comprehensive filtering.


268-275: addTb Function is Implemented Correctly!

The function uses the correct utility functions and updates the database appropriately for TorBox.


277-289: deleteTb Function is Implemented Correctly!

The function follows the correct pattern for deleting torrents and updating the state for TorBox.


585-605: Button Rendering Logic for TorBox is Correctly Integrated!

The conditional rendering ensures that the UI reflects the availability of the TorBox service, maintaining consistency with other services.

src/pages/library.tsx (10)

Line range hint 1-29: Imports for TorBox Functionality Look Good.

The added imports related to TorBox functionality are necessary for the integration and appear to be correctly implemented.


72-72: State Initialization for TorBox Syncing Looks Good.

The tbSyncing state variable is initialized correctly and follows the existing pattern for managing loading states of other services.


85-85: API Key Retrieval for TorBox is Correct.

The useTorBoxApiKey hook is used consistently with other API key retrievals, ensuring proper integration.


369-375: Initialization with TorBox Support is Correct.

The initialize function now includes fetchLatestTBTorrents, ensuring that TorBox torrents are fetched during the component's initial load.


1178-1188: Information Display for TorBox Torrents is Well-Implemented.

The handleShowInfoForTB function is consistent with similar functions for other services, ensuring uniformity in information display.


1523-1531: Event Handling for TorBox Torrents is Correct.

The event handlers have been updated to include logic for TorBox torrents, ensuring they are handled correctly alongside other services.

Also applies to: 1595-1603, 1609-1617, 1642-1650, 1656-1664


1015-1017: Adding TorBox Magnets is Implemented Correctly.

The logic for adding TorBox magnets in handleAddMagnet is consistent with the logic for other services, ensuring seamless integration.


1695-1700: TorBox Torrent Deletion is Properly Handled.

The usage of handleDeleteTbTorrent is consistent with other deletion functions, ensuring proper handling of TorBox torrent deletions.


1759-1761: Refreshing TorBox Torrents After Reinsertion is Correct.

The invocation of fetchLatestTBTorrents after reinserting torrents ensures that the TorBox torrent list is up-to-date.


286-353: TorBox Torrent Fetching Logic Looks Good.

The fetchLatestTBTorrents function correctly implements fetching, updating, and deleting logic for TorBox torrents, consistent with other services.

Ensure that this function is correctly integrated and invoked where necessary in the codebase.

Verification successful

Function fetchLatestTBTorrents is Properly Integrated.

The fetchLatestTBTorrents function is well-integrated within src/pages/library.tsx. It is invoked in various contexts, ensuring its functionality is utilized throughout the component.

  • Locations of Integration:
    • Used within asynchronous operations and callbacks.
    • Part of a batch fetch operation alongside other torrent fetching functions.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of `fetchLatestTBTorrents` function.

# Test: Search for the function usage. Expect: Occurrences within the initialization and torrent handling logic.
rg --type tsx -A 5 $'fetchLatestTBTorrents'

Length of output: 70


Script:

#!/bin/bash
# Description: Verify the integration of `fetchLatestTBTorrents` function.

# Test: Search for the function usage. Expect: Occurrences within the initialization and torrent handling logic.
rg --type ts -A 5 $'fetchLatestTBTorrents'

Length of output: 2790

@@ -28,6 +28,7 @@ export interface UserTorrent {
speed: number;
rdData?: TorrentInfoResponse;
adData?: MagnetStatus;
tbData?: any;
Copy link

Choose a reason for hiding this comment

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

Consider specifying a more precise type for tbData.

Using any can lead to potential type safety issues. If possible, define a specific type or interface for tbData to enhance type safety and maintainability.

src/services/torbox.ts Outdated Show resolved Hide resolved
src/services/torbox.ts Outdated Show resolved Hide resolved
src/services/torbox.ts Outdated Show resolved Hide resolved
src/services/torbox.ts Outdated Show resolved Hide resolved
Comment on lines +186 to +187
let size = file.size < 1024 ** 3 ? file.size / 1024 ** 2 : file.size / 1024 ** 3;
let unit = file.size < 1024 ** 3 ? 'MB' : 'GB';
Copy link

Choose a reason for hiding this comment

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

Consider using a utility function for file size calculation.

The logic for calculating file size in MB or GB can be abstracted into a utility function to improve readability and maintainability.

function formatFileSize(bytes: number): { size: number, unit: string } {
  const size = bytes < 1024 ** 3 ? bytes / 1024 ** 2 : bytes / 1024 ** 3;
  const unit = bytes < 1024 ** 3 ? 'MB' : 'GB';
  return { size, unit };
}
// Usage
const { size, unit } = formatFileSize(file.size);

@@ -32,7 +32,7 @@ You can share your whole collection or select specific items you want to share.

## Setup

0. Signup for a free tier plan at [PlanetScale](https://planetscale.com/) - this is a serverless MySQL database hosted in the cloud
0. Signup for a free tier plan at [Filess](https://filess.io/) - this is a serverless MySQL database hosted in the cloud
Copy link

Choose a reason for hiding this comment

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

Update database connection instructions.

The instructions still mention getting a connection string from PlanetScale, which should be updated to reflect the new database service, Filess.

- Get your Prisma database connection string from PlanetScale console
+ Get your Prisma database connection string from Filess console
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
0. Signup for a free tier plan at [Filess](https://filess.io/) - this is a serverless MySQL database hosted in the cloud
0. Signup for a free tier plan at [Filess](https://filess.io/) - this is a serverless MySQL database hosted in the cloud
Get your Prisma database connection string from Filess console

Comment on lines +103 to +116
export const handleAddAsMagnetInTb = async (
tbKey: string,
hash: string,
callback?: () => Promise<void>
) => {
try {
await createTorBoxTorrent(tbKey, [hash]);
if (callback) await callback();
toast('Successfully added torrent to TorBox!', magnetToastOptions);
} catch (error) {
toast.error(error as any);
throw error;
}
};
Copy link

Choose a reason for hiding this comment

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

Improve error handling in handleAddAsMagnetInTb.

The error message is directly passed to the toast. Consider providing a more user-friendly message.

toast.error('Failed to add torrent to TorBox. Please try again.');

src/utils/addMagnet.ts Show resolved Hide resolved
src/utils/instantChecks.ts Show resolved Hide resolved
@yowmamasita
Copy link
Collaborator

image

I've been slowly resolving the conflicts because it's been a while since I updated the public version. Just letting you know that I've been working on this

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.

3 participants