Compare commits

...

No commits in common. "code" and "main" have entirely different histories.
code ... main

3691 changed files with 278097 additions and 412 deletions

2
.client Normal file
View File

@ -0,0 +1,2 @@
SkFEn2Kxw2TF0A
3vxNivPb_OpnV6wZeX2Z80Et0wphiw

BIN
Changer.exe Normal file

Binary file not shown.

View File

@ -1,183 +0,0 @@
import wx
from glob import glob
from os import remove, getcwd, mkdir
from os.path import isfile, getsize, isdir
from subprocess import Popen, CREATE_NEW_CONSOLE, DETACHED_PROCESS
ids = {}
CONFIG = ".config"
HISTORY = ".history"
DESIGN = {
"Interval Text": (10, 13),
"Interval": (10, 30),
"Save": (11, 63),
"Hidden": (10, 93),
"Safe Mode": (10, 123),
"Clear Cache": (10, 150),
"Cache Information": (120,153),
"Clear History": (10, 180),
"History Information": (120,183),
"Refresh": (10, 210),
"Start": (10, 240)
}
def integrity_check():
for i in [1]:
if not isfile(CONFIG):
pass
elif len(open(CONFIG, "r").read().split()) < 4:
pass
else:
break
open(CONFIG, "w").write("600\n1\n0\n1")
print(CONFIG + " is missing")
print("generating " + CONFIG + " with default value of\n Interval = 600 seconds\n Save Wallpapers = True\n Start Hidden = False\n Approximate Time = True")
if not isfile(HISTORY):
open(HISTORY, "w").write("")
print(HISTORY + " is missing")
print("generating " + HISTORY)
if not isdir(".\\Images"):
mkdir(".\\Images")
print(getcwd() + "\\Images is missing")
print("generating " + getcwd() + ".\\Images")
class ChangerUI(wx.Frame):
def __init__(self, *args, **kw):
super(ChangerUI, self).__init__(*args, **kw)
self.InitUI()
def InitUI(self):
self.itxt = wx.StaticText(self, pos=DESIGN["Interval Text"], label="Interval:")
self.Intl = wx.TextCtrl(self, pos=DESIGN["Interval"], style=wx.TE_PROCESS_ENTER, size=(100, 24))
self.Intl.SetValue(open(CONFIG, "r").read().split()[0])
ids[self.Intl.GetId()] = "Interval"
self.Save = wx.CheckBox(self, pos=DESIGN["Save"], label="Save Wallpapers")
ids[self.Save.GetId()] = "Save"
self.Save.SetValue(int(open(CONFIG, "r").read().split()[1]))
self.Hd = wx.CheckBox(self, pos=DESIGN["Hidden"], label="Start Hidden")
ids[self.Hd.GetId()] = "Hidden"
self.Hd.SetValue(int(open(CONFIG, "r").read().split()[2]))
self.Ap = wx.CheckBox(self, pos=DESIGN["Safe Mode"], label="Safe Mode")
ids[self.Ap.GetId()] = "Safe"
self.Ap.SetValue(int(open(CONFIG, "r").read().split()[3]))
self.cl = wx.Button(self, label="Clear Cache", pos=DESIGN["Clear Cache"], size=(100, 28))
ids[self.cl.GetId()] = "Clear Cache"
self.clh = wx.Button(self, label="Clear History", pos=DESIGN["Clear History"], size=(100, 28))
ids[self.clh.GetId()] = "Clear History"
self.st = wx.Button(self, label="Start", pos=DESIGN["Start"], size=(100, 28))
ids[self.st.GetId()] = "Start"
self.rf = wx.Button(self, label="Refresh", pos=DESIGN["Refresh"], size=(100, 28))
ids[self.rf.GetId()] = "Refresh"
self.cinf = wx.StaticText( self,
label= str(int(sum([getsize(i) for i in glob("./Images/*.*")]) / 1024 / 10.24) / 100) + " MB, " + str(len(glob("./Images/*.*"))) + " Files",
pos=DESIGN["Cache Information"])
ids[self.cinf.GetId()] = "Cache Information"
self.hinf = wx.StaticText( self,
label= str(len(open(HISTORY, "r").read().split())) + " Entries",
pos=DESIGN["History Information"])
ids[self.hinf.GetId()] = "History Information"
self.Bind(wx.EVT_TEXT_ENTER, self.OnEnter)
self.Bind(wx.EVT_BUTTON, self.OnPress)
self.Bind(wx.EVT_CHECKBOX, self.OnPress)
self.Bind(wx.EVT_FSWATCHER, self.DirChanged)
self.SetSize((self.cinf.GetSize().x + 140, DESIGN["Start"][1] + 70))
self.SetTitle('Changer')
self.Centre()
def DirChanged(self, e):
self.cinf.SetLabel(str(int(sum([getsize(i) for i in glob("./Images/*.*")]) / 1024 / 10.24) / 100) + " MB, " + str(len(glob("./Images/*.*"))) + " Files")
def OnEnter(self, e):
if ids[e.GetId()] == "Interval":
try:
float(self.Intl.GetValue())
fr = open(CONFIG, "r")
c = fr.read().split()
fr.close()
fw = open(CONFIG, "w")
c[0] = self.Intl.GetValue()
fw.write("\n".join(c))
fw.close()
except:
print("Invalid Value!")
self.Intl.SetValue(open(CONFIG, "r").read().split()[0])
def OnPress(self, e):
if ids[e.GetId()] == "Clear Cache":
for i in [i for i in glob("./Images/*.*") if i.split(".")[-1] in ["jpg", "jpeg", "png"]]:
remove(i)
self.cinf.SetLabel(str(int(sum([getsize(i) for i in glob("./Images/*.*")]) / 1024 / 10.24) / 100) + " MB, " + str(len(glob("./Images/*.*"))) + " Files")
self.SetSize((self.cinf.GetSize().x + 140, DESIGN["Start"][1] + 70))
if ids[e.GetId()] == "Clear History":
open(".history", "w").write("")
self.hinf.SetLabel(str(len(open(HISTORY, "r").read().split())) + " Entries")
if ids[e.GetId()] == "Save":
fr = open(CONFIG, "r")
c = fr.read().split()
fr.close()
fw = open(CONFIG, "w")
c[1] = str(int(self.Save.GetValue()))
fw.write("\n".join(c))
fw.close()
if ids[e.GetId()] == "Hidden":
fr = open(CONFIG, "r")
c = fr.read().split()
fr.close()
fw = open(CONFIG, "w")
c[2] = str(int(self.Hd.GetValue()))
fw.write("\n".join(c))
fw.close()
if ids[e.GetId()] == "Safe":
fr = open(CONFIG, "r")
c = fr.read().split()
fr.close()
fw = open(CONFIG, "w")
c[3] = str(int(self.Ap.GetValue()))
fw.write("\n".join(c))
fw.close()
if ids[e.GetId()] == "Start":
if int(open(CONFIG, "r").read().split()[2]):
Popen(["wrapper.exe"], shell=True, creationflags=CREATE_NEW_CONSOLE)
else:
Popen(["wrapper.exe"], shell=True, creationflags=DETACHED_PROCESS)
if ids[e.GetId()] == "Refresh":
integrity_check()
self.hinf.SetLabel(str(len(open(HISTORY, "r").read().split())) + " Entries")
self.cinf.SetLabel(str(int(sum([getsize(i) for i in glob("./Images/*.*")]) / 1024 / 10.24) / 100) + " MB, " + str(len(glob("./Images/*.*"))) + " Files")
self.SetSize((self.cinf.GetSize().x + 140, DESIGN["Start"][1] + 70))
self.Intl.SetValue(open(CONFIG, "r").read().split()[0])
self.Save.SetValue(int(open(CONFIG, "r").read().split()[1]))
self.Hd.SetValue(int(open(CONFIG, "r").read().split()[2]))
self.Ap.SetValue(int(open(CONFIG, "r").read().split()[3]))
def main():
integrity_check()
app = wx.App()
cu = ChangerUI(None)
cu.Show()
app.MainLoop()
if __name__ == '__main__':
main()

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Surferlul
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,19 +1,32 @@
# Wallpaper Changer Build Code # Wallpaper-Changer
Wallpaper Changer for Windows using the r/Wallpaper subreddit
REQUIREMENTS: YOU DO NOT NEED PYTHON TO RUN THIS PROGRAMM
Python 3 If you own python you can download the non-compiled version from the "python" branch
Following modules: If you want to compile it yourself you can download the code from the "code" branch
* cx_Freeze (pip install cx-Freeze)
* praw (pip install praw) If you want a more compact version and don't need a UI you can download the program from the "noui_main" branch
* progressbar (pip install progressbar)
* imgur_downloader (pip install imgur-downloader) This app uses the reddit api for Python.\
* wx (pip install wxPython) The reddit api has limits.\
<br/> The app already had a configured ".client" file with a throwaway client id and client secret so you don't have to create your own reddit app.\
Managing script (UI): Changer.py. <br/> If it is used to often it may be slow.\
Main loop: wrapper.py. <br/> If possible create a reddit app at https://ssl.reddit.com/prefs/apps/ on your reddit account and replace the default id and secret in the ".client" file with your own.
Download, setting wallpaper etc.: backend.py
<br/>
<br/>
To build execute "build.py" To do so:
<pre>
1. Click on "Create App" and fill in the blanks.
2. Select the "script" radio button.
The "about url" is just information.
The "redirect uri" isn't important and can be something like http://localhost.
Under the name of the app it should say "personal use script".
Underneath you should find your client id.
Put the client id in the first line of a file titled ".client" in the same directory as "Changer.exe".
You should find the client secret as "secret".
Put the client secret in the second line of the ".client" file.
You're good to go!
</pre>

BIN
backend.exe Normal file

Binary file not shown.

View File

@ -1,109 +0,0 @@
from ctypes import windll
from praw import Reddit
from glob import glob
from time import sleep
from time import time
from urllib.request import urlretrieve
from os import getcwd, remove, system
import progressbar
import urllib.request
from imgur_downloader import ImgurDownloader
import _thread
from subprocess import Popen, CREATE_NEW_CONSOLE
CONFIG = ".config"
CLIENT = ".client"
intrvl = float(open(CONFIG, "r").read().split()[0])
imgpath = ""
start = time()
client = open(CLIENT, "r").read().split()
class NoImage(Exception):
pass
reddit = Reddit(client_id=client[0],
client_secret=client[1],
user_agent='Wallpaper changer by u/Surferlul')
class MyProgressBar():
def __init__(self):
self.pbar = None
def __call__(self, block_num, block_size, total_size):
if not self.pbar:
self.pbar=progressbar.ProgressBar(maxval=total_size)
self.pbar.start()
downloaded = block_num * block_size
if downloaded < total_size:
self.pbar.update(downloaded)
else:
self.pbar.finish()
def del_file(path, Seconds=10):
Popen("powershell.exe Sleep(" + str(Seconds) + "); Remove-Item .\\Images\\" + path, shell=True, creationflags=CREATE_NEW_CONSOLE)
posts = open(".history", "r").read()
for i in reddit.subreddit("wallpaper").hot(limit = 1000):
if i.url not in posts:
submission = i
break
open(".history", "a").write(submission.url + "\n")
try:
if "imgur" in submission.url:
if submission.url.split("/")[-1].split(".")[-1] not in ["jpg", "jpeg", "png"]:
print("Downoading", submission.url)
else:
print("Downoading", submission.url, "as", submission.url.split("/")[-1])
ImgurDownloader(
submission.url,
"./Images/",
file_name=submission.url.split("/")[-1]
if submission.url.split("/")[-1].split(".")[-1] not in ["jpg", "jpeg", "png"]
else submission.url.split("/")[-1].split(".")[0]
).save_images()
if submission.url.split("/")[-1].split(".")[-1] not in ["jpg", "jpeg", "png"]:
windll.user32.SystemParametersInfoW(20, 0, getcwd() + "\\" + glob("./Images/" + submission.url.split("/")[-1] + ".*")[0], 0)
if not int(open(CONFIG, "r").read().split()[1]):
del_file(glob(submission.url.split("/")[-1] + ".*")[0])
else:
windll.user32.SystemParametersInfoW(20, 0, getcwd() + "\\Images\\" + submission.url.split("/")[-1] , 0)
if not int(open(CONFIG, "r").read().split()[1]):
del_file(submission.url.split("/")[-1])
else:
if submission.url.split("/")[-1].split(".")[-1] not in ["jpg", "jpeg", "png"]:
raise NoImage
imgpath = "Images\\" + submission.url.split("/")[-1]
print("Downoading", submission.url, "as", submission.url.split("\\")[-1])
urlretrieve(submission.url, imgpath, MyProgressBar())
windll.user32.SystemParametersInfoW(20, 0, getcwd() + "\\" + imgpath, 0)
if not int(open(CONFIG, "r").read().split()[1]):
del_file(submission.url.split("/")[-1])
end = time()
intrvl += start - end
if intrvl >= 0:
pbar = progressbar.ProgressBar(maxval=intrvl)
pbar.start()
if intrvl < 10:
for i in range(1, int(intrvl * 10) + 1):
sleep(intrvl / int(intrvl * 10))
try:
pbar.update(intrvl / int(intrvl * 10) * i)
except:
pbar.update(int(intrvl))
print("test")
else:
for i in range(1, 101):
sleep(intrvl / 100)
pbar.update(intrvl / 100 * i)
pbar.finish()
elif int(open(CONFIG, "r").read().split()[3]):
intrvl -= 2 * (start - end)
print("Interval was rounded up to " + str(round(intrvl * 100) / 100) + "s because the download needed longer than the interval.")
except NoImage:
print("Error: Url doesn't point to an Image")
except Exception as E:
print("Error: " + type(E).__name__)

View File

@ -1,20 +0,0 @@
from subprocess import call, Popen, DETACHED_PROCESS
from shutil import rmtree
from os.path import isdir
if isdir(".\\build"):
print("Removing .\\build")
rmtree(".\\build")
if isdir(".\\noui_build"):
print("Removing .\\noui_build")
rmtree(".\\noui_build")
Popen(["powershell", """python3 noui_setup.py build; python3 -c "input('\\n\\n________________________________\\nBUILD FINISHED\\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\\n\\n')\""""], shell=True, creationflags=DETACHED_PROCESS)
call("python3 setup.py build", shell=True)
print(
"""
________________________________
BUILD FINISHED
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
"""
)
input()

BIN
lib/PIL/BdfFontFile.pyc Normal file

Binary file not shown.

BIN
lib/PIL/BlpImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/BmpImagePlugin.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/ContainerIO.pyc Normal file

Binary file not shown.

BIN
lib/PIL/CurImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/DcxImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/DdsImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/EpsImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ExifTags.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/FliImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/FontFile.pyc Normal file

Binary file not shown.

BIN
lib/PIL/FpxImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/FtexImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/GbrImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/GdImageFile.pyc Normal file

Binary file not shown.

BIN
lib/PIL/GifImagePlugin.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/GimpPaletteFile.pyc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/IcnsImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/IcoImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/Image.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageChops.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageCms.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageColor.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageDraw.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageDraw2.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageEnhance.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageFile.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageFilter.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageFont.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageGrab.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageMath.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageMode.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageMorph.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageOps.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImagePalette.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImagePath.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageQt.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageSequence.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageShow.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageStat.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageTk.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageTransform.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImageWin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/ImtImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/IptcImagePlugin.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/JpegImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/JpegPresets.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/MicImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/MpegImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/MpoImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/MspImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PSDraw.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PaletteFile.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PalmImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PcdImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PcfFontFile.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PcxImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PdfImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PdfParser.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/PngImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PpmImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PsdImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/PyAccess.pyc Normal file

Binary file not shown.

BIN
lib/PIL/SgiImagePlugin.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/SunImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/TarIO.pyc Normal file

Binary file not shown.

BIN
lib/PIL/TgaImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/TiffImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/TiffTags.pyc Normal file

Binary file not shown.

BIN
lib/PIL/VCRUNTIME140.dll Normal file

Binary file not shown.

BIN
lib/PIL/WalImageFile.pyc Normal file

Binary file not shown.

BIN
lib/PIL/WebPImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/WmfImagePlugin.pyc Normal file

Binary file not shown.

Binary file not shown.

BIN
lib/PIL/XbmImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/XpmImagePlugin.pyc Normal file

Binary file not shown.

BIN
lib/PIL/__init__.pyc Normal file

Binary file not shown.

BIN
lib/PIL/__main__.pyc Normal file

Binary file not shown.

BIN
lib/PIL/_binary.pyc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More