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

No explicit header set for the DOWNLOAD_SESSION #483 #536

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 8, 2024

…ads a resource from a specified URL while including a custom User-Agent header for identification. It constructs the User-Agent string using the application's version and the user's email, sends an authenticated GET request to the URL, and saves the downloaded content to a file if the request is successful. The script also includes an example usage section where the user can specify their email, API token, and download URL.

…ads a resource from a specified URL while including a custom User-Agent header for identification. It constructs the User-Agent string using the application's version and the user's email, sends an authenticated GET request to the URL, and saves the downloaded content to a file if the request is successful. The script also includes an example usage section where the user can specify their email, API token, and download URL.
@@ -11,6 +11,8 @@

import requests
from requests_file import FileAdapter
from . import ricecooker # Import to access the version
from .auth import get_user_email # Assuming you have a function to get the user's email
Copy link
Member

Choose a reason for hiding this comment

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

This module doesn't exist.

# Set User-Agent header for DOWNLOAD_SESSION
user_email = authenticate_user(token)[0] # Get the user's email
config.DOWNLOAD_SESSION.headers.update({
"User-Agent": f"Ricecooker/{ricecooker.__version__} bot ({user_email})"
Copy link
Member

Choose a reason for hiding this comment

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

Is the username not the user_email in this case?

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

I think the change in commands.py is all that is needed.

This rather has the appearance of having been automatically generated by a generative AI, as some of the code here refers to non-existent modules.

Please before submitting a pull request, test that your code actually works and doesn't break things.

@@ -94,6 +96,12 @@ def uploadchannel( # noqa: C901
username = ""
token = ""

# Set User-Agent header for DOWNLOAD_SESSION
user_email = authenticate_user(token)[0] # Get the user's email
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why we need to reauthenticate here, we already got the username above.

@rtibbles rtibbles self-assigned this Nov 8, 2024
@ghost
Copy link
Author

ghost commented Nov 13, 2024

Ok ,sure i will correct them.

Repository owner closed this by deleting the head repository Nov 14, 2024
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.

2 participants