-
Notifications
You must be signed in to change notification settings - Fork 54
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
Conversation
…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 |
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.
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})" |
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.
Is the username
not the user_email in this case?
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.
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 |
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.
Not sure why we need to reauthenticate here, we already got the username above.
Ok ,sure i will correct them. |
…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.