amcquade / fresh_script

Find Spotify tracks posted to the HipHopHeads subreddit and add them to a Spotify playlist.
MIT License
91 stars 61 forks source link

`praw.Reddit` instance does not use a unique user-agent #63

Closed pricebenjamin closed 4 years ago

pricebenjamin commented 4 years ago

The reddit API rules ask that the supplied user-agent string be

unique and descriptive, including the target platform, a unique application identifier, a version string, and your username as contact information, in the following format: <platform>:<app ID>:<version string> (by /u/<reddit username>)

Currently, all fresh_script users have the same user-agent, defined by the createPrawConfig function: https://github.com/amcquade/fresh_script/blob/29a482a14638531f2177aa58d98dd6ef1e6c4870/fresh.py#L56-L60

The createPrawConfig function creates a site_name called 'bot1' in a local praw.ini file. This site_name is then used to create a praw.Reddit instance within main: https://github.com/amcquade/fresh_script/blob/29a482a14638531f2177aa58d98dd6ef1e6c4870/fresh.py#L377

One solution would be to override the user_agent string when creating the praw.Reddit instance:

user_agent = ' '.join([
    "Python3:FreshScript:(commit 29a482a)",
    "(by /u/<reddit_user>)",
    "(https://github.com/amcquade/fresh_script)"
])
reddit = praw.Reddit('bot1', user_agent=user_agent)

A helper function to generate the user string would be useful. We would also need to store the user's reddit username in one of the configuration files (see #62).

masihtamsoy commented 4 years ago

Hi, want to look into this issue. Please provide me initials to get started.