From da02b87fd53c80d41c638db60f689928bf4df29e Mon Sep 17 00:00:00 2001 From: Ahamed Musthafa Date: Mon, 1 Oct 2018 12:01:58 +0530 Subject: [PATCH 1/3] Create program.py --- PythonWallpaperChanger/program.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 PythonWallpaperChanger/program.py diff --git a/PythonWallpaperChanger/program.py b/PythonWallpaperChanger/program.py new file mode 100644 index 0000000..104d6fe --- /dev/null +++ b/PythonWallpaperChanger/program.py @@ -0,0 +1,29 @@ +'''This program extracts some pictures from the NatGeo gallery and store it as local file, + then change it as the desktop wallpaper''' + +import os +import ctypes +import urllib.request as u +import requests, random +from datetime import datetime as dt + +i='1' + +try: + day = dt.now().date() + day = str(day) + temp1 = int(day[-1]) + tnum = [9000,8900,8930,9010,8920,8970,8950] + temp = 2*temp1 - 1 + t1 = random.choice(tnum)+temp + i = str(t1) + try: + url = 'https://assets-natgeotv.fnghub.com/POD/'+i+'.jpg' + + except: + print('Server Error !') + path = 'C:\\Users\\Sabi\\Downloads\\m\\pic_dtop\\'+day+'.jpg' + file = u.urlretrieve(url,path) + ctypes.windll.user32.SystemParametersInfoW(20, 0, path , 0) +except Exception as e: + print('Some Technical issues !') From b2e0775e98f1bd8497b1d9fc39e22e65d9749402 Mon Sep 17 00:00:00 2001 From: Ahamed Musthafa Date: Sat, 6 Oct 2018 08:30:14 +0530 Subject: [PATCH 2/3] Update program.py --- PythonWallpaperChanger/program.py | 1 + 1 file changed, 1 insertion(+) diff --git a/PythonWallpaperChanger/program.py b/PythonWallpaperChanger/program.py index 104d6fe..ea805bb 100644 --- a/PythonWallpaperChanger/program.py +++ b/PythonWallpaperChanger/program.py @@ -22,6 +22,7 @@ except: print('Server Error !') + #Change the path for the file in your machine path = 'C:\\Users\\Sabi\\Downloads\\m\\pic_dtop\\'+day+'.jpg' file = u.urlretrieve(url,path) ctypes.windll.user32.SystemParametersInfoW(20, 0, path , 0) From ede82fcb4214934a7464fc19009b3f712cac9eca Mon Sep 17 00:00:00 2001 From: Ahamed Musthafa Date: Sun, 7 Oct 2018 11:48:49 +0530 Subject: [PATCH 3/3] Update program.py --- PythonWallpaperChanger/program.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/PythonWallpaperChanger/program.py b/PythonWallpaperChanger/program.py index ea805bb..67918f6 100644 --- a/PythonWallpaperChanger/program.py +++ b/PythonWallpaperChanger/program.py @@ -22,9 +22,11 @@ except: print('Server Error !') - #Change the path for the file in your machine - path = 'C:\\Users\\Sabi\\Downloads\\m\\pic_dtop\\'+day+'.jpg' - file = u.urlretrieve(url,path) - ctypes.windll.user32.SystemParametersInfoW(20, 0, path , 0) + def get_download_path: + home = os.path.expanduser("~") + downloads_folder = os.path.join(home, "Downloads") + path = os.path.join(downloads_folder, 'day.jpg'.format(day=day)) + file = u.urlretrieve(url, path) + ctypes.windll.user32.SystemParametersInfoW(20, 0, path , 0) except Exception as e: print('Some Technical issues !')