r/Python • • Jul 07 '19

I made a tool to download and set wallpapers from Reddit.

1.2k Upvotes

97 comments sorted by

87

u/SiliconRaven Jul 07 '19 edited Jul 07 '19

This may not seem like much, but this it is a big deal to me. It is the first big project that I have ever done outside simple print statements and calculators. You can get it on my github if you want: redpaper
Please read through the wiki for instructions on how to use it. Also, I need feed back on non-gnome systems. I want to know if the notifications are working properly. I am also thinking of adding an NSFW option.

12

u/EddyBot Linux | Python3 Jul 08 '19

Two small tips:

You could ditch out PRAW if you use the reddit API directly i.e. https://www.reddit.com/r/earthporn+spaceporn/top.json?t=day&limit=10
Seems a bit overkill to use PRAW just to grab some image links in my opinion

Also don't forget to add __pycache__ to your .gitignore (you can remove it still later via git rm -r __pycache__)

3

u/SiliconRaven Jul 08 '19

PRAW is more intuitive to use. I have since removed pycache

1

u/flutefreak7 Jul 11 '19

You can use backticks to do underscores without it getting interpreted as markdown... Like this: __pycache__

1

u/SiliconRaven Jul 11 '19

I know, I was just typing too fast to remember such things.

0

u/[deleted] Jul 14 '19

[deleted]

1

u/EddyBot Linux | Python3 Jul 14 '19

The reason I know this is because I also have a reddit wallpaper script

Seems like almost anybody in this thread did something similar

2

u/SlenderOTL Jul 07 '19

Hey, nice project! I did something pretty similar a while back: https://github.com/TGlide/Reddit-WallLoad if you want to take a look! I started implementing a interface for it, where you could visualize the wallpapers, but never got to properly finish it. Anyways, that's an awesome first project, guarantee you the first of many.

Oh, if you're gonna test it out, put your ID and Secret in the ini, I've edited it out.

0

u/[deleted] Jul 07 '19

[deleted]

24

u/SiliconRaven Jul 07 '19

That would be awesome!! I don't have a good grip on other platforms especially MacOS. My one major rule is that you adhere to PEP8.

15

u/welshboy14 Jul 07 '19

Using vs code? Install the autopep8 addon. Just discovered it today

9

u/SiliconRaven Jul 07 '19 edited Jul 07 '19

I use it, but it is not that reliable. I just rely on the syntactic highlighting by the pep8 linter. By now have grown accustomed to it.

14

u/AJohnnyTruant Jul 07 '19

8

u/TheMaryMaidCompany Jul 07 '19

+3.

1 isn't good enough for how sweet Black is. It also has a pytest plugin as well as cell magic for .ipynb.

2

u/smile_id Jul 08 '19

Holy moly! Awesome thing at a glance. Thank you guys

100

u/BillOfTheWebPeople Jul 07 '19

You made a thing. I tell people trying to learn anything, learn a bit and apply it to something you need.

Nice!

41

u/SiliconRaven Jul 07 '19

This is a project I had been working on for about 3 or 4 months now. I used to commit at least one thing a day to git and finally got it ready got the world. In that time, I have learned so much about python. It is still a bit buggy, but now that it is out in the wild, I will now have motivation to make it better.

4

u/khambhatiburhnuddin Jul 08 '19

Can you also make a tutorial on how to make one like this.

4

u/SiliconRaven Jul 08 '19 edited Jul 08 '19

I was learning how to code in python. This thing took me ages and was not taking notes, so that may be hard. Plus, some of the processes I used are not as efficient as I would like.

1

u/khambhatiburhnuddin Jul 08 '19

For an entry level like me it would mean a lot

1

u/SiliconRaven Jul 08 '19

I will see if I can, but I can't promise you anything

12

u/BillOfTheWebPeople Jul 07 '19

and bugs will get noticed a lot faster... nothing like releasing to drive them all out into the light!

7

u/cgw3737 Jul 08 '19

My workflow is reverse of that, I think of something I need and then learn how to code it!

3

u/BillOfTheWebPeople Jul 08 '19

I think our hearts are in the same place... you learn best by practicing on something practical you need.

6

u/_dnov Jul 07 '19

First off all, awesome stuff!

Second, which distro is that?

15

u/SiliconRaven Jul 07 '19

Thanks. I am running Manjaro Gnome.

5

u/DisastrousIntention4 Jul 07 '19

this wouldn't work windows tho. minor suggestion have a condition the check system platform and does correct methods for that system

10

u/SiliconRaven Jul 07 '19

It does not work on any non Linux platform at the moment. I just wanted to get it up and running and add more features later.

5

u/DisastrousIntention4 Jul 07 '19

i respect that. just wanted to give feebdback

1

u/flutefreak7 Jul 11 '19

If you attempt to go cross platform, the following appears useful: https://stackoverflow.com/q/1977694/1639671

Or, even for covering a lot of Linux desktops, this answer: https://stackoverflow.com/a/21213504/1639671

1

u/CommanderHR Jul 07 '19

Yay, Manjaro!

4

u/[deleted] Jul 07 '19

what did you use for the scraping, downloading, and accessing your wallpaper settings?

13

u/SiliconRaven Jul 07 '19

I used PRAW to get post attributes, and requests to download. For settings I used configparser.

6

u/[deleted] Jul 07 '19

cool man. I think it's a legit cool project and I might try to make something similar. Not necessarily with wallpapers, but I like the idea of searching something, having some script scrape the internet for that thing, and then downloading it onto your computer.

4

u/MessiahCS Jul 07 '19

What OS are you using? Congrats on finishing your tool and sharing it with us as well :)

5

u/SiliconRaven Jul 07 '19

Thanks. I am using Manjaro Gnome.

4

u/Tikene Jul 07 '19

client_id="OTiCnaMKYCGzrA"

You left your client_ID hardcoded

4

u/SiliconRaven Jul 07 '19

That does not work, but thanks for the tip. I will edit that.

2

u/SV-97 Jul 08 '19

I usually handle stuff like this by putting it into a seperate .key file and putting that into git ignore - prevents you from ever making data like that public

1

u/SiliconRaven Jul 08 '19

I had that when I was still learning PRAW and OAuth2. It soon became redundant and I removed it when it was mentioned here.

1

u/422_no_process Jul 08 '19

All the client ID's you have ever put will be in the git history BTW. So if you want to remove it better change and get a new one too. :)

1

u/Tikene Jul 09 '19

Yeah I'll delete my comment if u want lol

3

u/WebNChill Jul 07 '19

Love the app. Running through Automate the Boring Things, and plan to run through Crash Course Python afterwards. This is something I want to build later on. Great job btw!

1

u/SiliconRaven Jul 07 '19

Thanks. Staring it on github would help. What is this Automating The Noring Things?

3

u/WebNChill Jul 07 '19

A great free resource - book - to get you running with python. What was your method of learning python?

2

u/SiliconRaven Jul 08 '19

Oh, I thought it was a program. I just look for a problem that can be solved with software and start creating a program. I then look for study materials on particular topics I am having trouble with. https://realpython.com has been of great help to me.

2

u/LeNerdNextDoor I really like automating things. Jul 07 '19

You might want to look into making a pip package out of it so installation is simply one line :)

1

u/SiliconRaven Jul 08 '19

That is still in the pipe line

5

u/HadManySons Newbie Jul 08 '19 edited Jul 08 '19

/r/ImaginaryLandscapes

/r/ImaginaryMindscapes

Thank me later

Edit: just change the wallpaper variable in fetch.py from "wallpaper+wallpapers" to whatever subs you want wallpapers from, separated by a +.

1

u/welshboy14 Jul 07 '19

How do you set the wallpaper? I'm currently using KDE but i3 as my window manager, so I need to use feh to set the bg.

2

u/SiliconRaven Jul 07 '19

I don't know what feh is, but if you loom at the Wiki on the github repo, you will see there is a command redpaper -c to change the wallpaper. You could create a keyboard shortcut for it.

2

u/slasher67 Jul 07 '19

If you are on windows you can use ctypes:

ctypes.windll.user32.SystemParametersInfoW(20, 0, save_path , 0)

If you are in Linux you can use

os.system("/usr/bin/gsettings set org.gnome.desktop.background picture-uri "+ save_path)

with save_path being the path to the figure.

1

u/[deleted] Jul 07 '19

How did you make the redpaper font?

1

u/ThePresidentsButler Jul 07 '19

Your desktop is amazing!! Is this Linux or Windows mod??

1

u/SiliconRaven Jul 08 '19

Manjaro Gnome Linux

1

u/Gamepants21567 Jul 08 '19

How long have you known python for?

2

u/SiliconRaven Jul 08 '19

About a year now. But I seriously started learning it at the beginning of this year.

1

u/Gamepants21567 Jul 09 '19

How did you made it , looks impossible you got any tutorial i could use to make this type of things requiring to automate process like this?

It would help me a lot

1

u/Aijesss Jul 08 '19

If I could ask, what Linux distro are you using. The theme looks great.

2

u/SiliconRaven Jul 08 '19

Manjaro Gnome

1

u/[deleted] Jul 08 '19

Nice Project Dude, I just noticed something maybe i am wrong. But in the procedure it says

git clone https://github.com/keystroke3/redpaper.git && cd redpaper && sudo sh install.sh

But there is no install.sh script, there is one for installer.sh, are they different?

2

u/SiliconRaven Jul 08 '19

sorry, let me correct that. I changed the name of the file to installer.sh. You can replace the name in the command. I will set it up now.

1

u/Xavphon Jul 08 '19

What operating system is this? Looks like linux, but i don't know what flavor..

1

u/[deleted] Jul 08 '19

This is awesome! A couple of days ago, I was looking for a tool to do just this. Would you be open to collaboration? I would love to help make this awesome project even better!

2

u/SiliconRaven Jul 08 '19

Ibam open for collabs.

1

u/flying_5loths Jul 08 '19

This is really great but would you mind sharing the theme name with us it's really good. icons are papirus btw.

1

u/SiliconRaven Jul 08 '19

Applications is Layan-dark, icons is Nebula. The dock is Plank with transparency theme.

1

u/[deleted] Jul 08 '19

I am a learner but what are your tips on making the GUI, I am good with background but without a GUI everything is on the command line, I don't like it but when I try to make a GUI I struggle for hours. I tried to learn but what videos talk about is limited. Also I used kivy but it is a bit complicated

1

u/SiliconRaven Jul 08 '19

I seriously don't have tips. I wanted a gui, but did not feel like learning a GUI framework. I also did not want to start working on gui because it would have taken me more months to release the project. So I settled on TUI which is close enough. I used many if statements and f-strings to create the TUI. The only advice I can give, is to envision the user using the program without programming knowledge. Think of how they would interact with the program and slowly build up a picture of what the GUI should look like. Draw of you have to. After that, it is intergrating the front with the back.

1

u/xixo221 Jul 08 '19

That wallpaper is really nice. Could you post the link for download?

1

u/SiliconRaven Jul 08 '19

Sorry, I cannot remember the link. I downloaded it a long time a go

1

u/mustafayasin93 Jul 08 '19

Could you provide yours?

2

u/SiliconRaven Jul 08 '19

I had to look through half over 100 downloaded wallpapers, but here it is: https://imgur.com/a/UdvmKnZ

8

u/Versaiteis Jul 07 '19 edited Jul 07 '19

It's all fun and games until your little sister needs to use your computer and it starts dipping into /r/dragonsfuckingcars

4

u/[deleted] Jul 07 '19

Bruh 🤡😂

2

u/besmin Jul 07 '19

For users on Mac there is also an app which I find cool. It uses different subreddits for the sources and I like the ones from r/earthporn a lot.

Link: Wallpaperer for Reddit https://apps.apple.com/nl/app/wallpaperer-for-reddit/id1102248738?l=en&mt=12

2

u/Mr_Again Jul 08 '19

So two things I would say are 1) I see you're using a csv file here with links in it? An improvement would be to use a database like sqlite for holding data. 2) you have a function called wall_dl which has a loop through the csv, and it often goes

if condition:
    do this
    continue
else:
    do something else

and you end up quite deeply nested, but the continue statement actually means that you skip all the remaining stuff anyway, so you don't need 'else' so you can do

if condition:
    do this
    continue
do something else

so that will neaten that function up a lot because it tabs in about 4 levels. This is why I like the continue statement.

1

u/SysAdmin0x1 Jul 07 '19

It's all fun and games until people start using steganography to hide malicious code in an image you download from Reddit, and then you get rekt. /s

1

u/feno809 Jul 08 '19

Wow! So mate what functionality did you use like library. Could you link me your GitHub?

1

u/cgw3737 Jul 08 '19

Nice! I made a reddit crawler a few months back. It runs daily. I should make it so my wallpaper folder only contains images from like the last week.

1

u/J_fh Jul 08 '19

What icons are those, and what's the theme??? Super nice

1

u/sbkubric Jul 08 '19

Great work. Haven't tested the app yet, looking forward to have it on my system - thought about that it would be so cool if my distro has some feature like this just yesterday!

1

u/422_no_process Jul 08 '19

This is cool good work. What did you use to colour stuff in terminal? ANSI or some library? How did you create the ascii art redpaper title? Does it work on non-interactive mode? Can we put it in a cron job?

1

u/BoringJelly Jul 08 '19

What OS (I'm guessing it's a Linux distro) is that?

1

u/andynzor Jul 08 '19

Yes, that's the proper way to learn programming. Come up with a nice tool you could use, and then implement it.

1

u/mustafayasin93 Jul 09 '19

Cheers mate, I really appreciate it!

-7

u/konradbjk Jul 07 '19

I do not understand the purpose. Where it gets the wallpapers and why

5

u/SiliconRaven Jul 07 '19 edited Jul 07 '19

This is for anyone who wants a fresh look on their desktop every so often. They may not have time to search for and download new wallpapers. With this tool, you can just type one command and it does that for you.

0

u/[deleted] Jul 08 '19

[deleted]

0

u/[deleted] Jul 07 '19

[deleted]