diff --git a/.gitignore b/.gitignore index 77aed6e..368df05 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ idlemaster.log +settings.txt diff --git a/Releases/Linux/Linux-readme.txt b/Releases/Linux/Linux-readme.txt index 7276c12..d7d8621 100644 --- a/Releases/Linux/Linux-readme.txt +++ b/Releases/Linux/Linux-readme.txt @@ -3,9 +3,10 @@ In the spirit of open source and free software there are no Linux binaries provi The script needs these Python 2 packages to run: requests beautifulsoup4 -pillow (with jpeg and tk support) colorama +gtk2 +notify Examples for packages that meet the dependencies: -Ubuntu: python-bs4, python-requests, python-pil.imagetk, python-colorama -Arch Linux: python2-beautifulsoup4, python2-requests, python2-pillow, tk, python2-colorama +Ubuntu: python-bs4 python-requests python-colorama python-gtk2 python-notify +Arch Linux: python2-beautifulsoup4 python2-requests python2-pillow python2-colorama pygtk python2-notify diff --git a/Releases/Linux/settings.txt b/Releases/Linux/settings.txt deleted file mode 100644 index 68bd419..0000000 --- a/Releases/Linux/settings.txt +++ /dev/null @@ -1,4 +0,0 @@ -sessionid = "" -steamLogin = "" -steamparental = "" -sort = "" \ No newline at end of file diff --git a/Releases/Linux/settings.txt.example b/Releases/Linux/settings.txt.example new file mode 100644 index 0000000..cac0f40 --- /dev/null +++ b/Releases/Linux/settings.txt.example @@ -0,0 +1,6 @@ +sessionid = "" +steamId = "your-account" +steamLogin = "" +steamLoginSecure = "" +steamparental = "" +sort = "" diff --git a/Releases/Linux/start.py b/Releases/Linux/start.py index f514f1f..f6ef6e8 100644 --- a/Releases/Linux/start.py +++ b/Releases/Linux/start.py @@ -32,26 +32,42 @@ authData["steamparental"]="" authData["hasPlayTime"]="false" execfile("./settings.txt",authData) - myProfileURL = "http://steamcommunity.com/profiles/"+authData["steamLogin"][:17] + myProfileURL = "https://steamcommunity.com/id/"+authData["steamId"] except: logging.warning(Fore.RED + "Error loading config file" + Fore.RESET) raw_input("Press Enter to continue...") sys.exit() - + if not authData["sessionid"]: logging.warning(Fore.RED + "No sessionid set" + Fore.RESET) raw_input("Press Enter to continue...") sys.exit() - + if not authData["steamLogin"]: - logging.warning(Fore.RED + "No steamLogin set" + Fore.RESET) + logging.warning(Fore.YELLOW + "No steamLogin set" + Fore.RESET) + +if not authData["steamLoginSecure"]: + logging.warning(Fore.YELLOW + "No steamLoginSecure set" + Fore.RESET) + +if not authData["steamLoginSecure"] and not authData["steamLogin"]: + logging.warning(Fore.RED + "No steamLogin and steamLoginSecure set" + Fore.RESET) raw_input("Press Enter to continue...") sys.exit() def generateCookies(): global authData try: - cookies = dict(sessionid=authData["sessionid"], steamLogin=authData["steamLogin"], steamparental=authData["steamparental"]) + cookies = dict( + sessionid=authData["sessionid"], + timezoneOffset=authData["timezoneOffset"], + steamCountry=authData["steamCountry"] + ) + if "steamLogin" in authData: + cookies["steamLogin"] = authData["steamLogin"] + if "steamLoginSecure" in authData: + cookies["steamLoginSecure"] = authData["steamLoginSecure"] + if "steamparental" in authData: + cookies["steamparental"] = authData["steamparental"] except: logging.warning(Fore.RED + "Error setting cookies" + Fore.RESET) raw_input("Press Enter to continue...") @@ -65,7 +81,7 @@ def dropDelay(numDrops): else: baseDelay = (5*60) return baseDelay - + def idleOpen(appID): try: logging.warning("Starting game " + getAppName(appID) + " to idle cards") @@ -79,7 +95,7 @@ def idleOpen(appID): elif sys.platform.startswith('darwin'): process_idle = subprocess.Popen(["./steam-idle", str(appID)]) elif sys.platform.startswith('linux'): - process_idle = subprocess.Popen(["python2", "steam-idle.py", str(appID)]) + process_idle = subprocess.Popen(["python2", "steam-idle.py", str(appID), getPlainAppName(appID)]) except: logging.warning(Fore.RED + "Error launching steam-idle with game ID " + str(appID) + Fore.RESET) raw_input("Press Enter to continue...") @@ -105,7 +121,7 @@ def chillOut(appID): time.sleep(5*60) try: rBadge = requests.get(myProfileURL+"/gamecards/" + str(appID) + "/",cookies=cookies) - indBadgeData = bs4.BeautifulSoup(rBadge.text) + indBadgeData = bs4.BeautifulSoup(rBadge.text, 'lxml') badgeLeftString = indBadgeData.find_all("span",{"class": "progress_info_bold"})[0].contents[0] if "card drops" in badgeLeftString: stillDown = False @@ -116,7 +132,7 @@ def chillOut(appID): def getAppName(appID): try: - api = requests.get("http://store.steampowered.com/api/appdetails/?appids=" + str(appID) + "&filters=basic") + api = requests.get("https://store.steampowered.com/api/appdetails/?appids=" + str(appID) + "&filters=basic") api_data = json.loads(api.text) return Fore.CYAN + api_data[str(appID)]["data"]["name"].encode('ascii', 'ignore') + Fore.RESET except: @@ -124,7 +140,7 @@ def getAppName(appID): def getPlainAppName(appid): try: - api = requests.get("http://store.steampowered.com/api/appdetails/?appids=" + str(appID) + "&filters=basic") + api = requests.get("https://store.steampowered.com/api/appdetails/?appids=" + str(appID) + "&filters=basic") api_data = json.loads(api.text) return api_data[str(appID)]["data"]["name"].encode('ascii', 'ignore') except: @@ -155,7 +171,7 @@ def get_blacklist(): try: badgesLeft = [] - badgePageData = bs4.BeautifulSoup(r.text) + badgePageData = bs4.BeautifulSoup(r.text, 'lxml') badgeSet = badgePageData.find_all("div",{"class": "badge_title_stats"}) except: logging.warning(Fore.RED + "Error finding drop info" + Fore.RESET) @@ -170,7 +186,7 @@ def get_blacklist(): currentpage = 2 while currentpage <= badgePages: r = requests.get(myProfileURL+"/badges/?p="+str(currentpage),cookies=cookies) - badgePageData = bs4.BeautifulSoup(r.text) + badgePageData = bs4.BeautifulSoup(r.text, 'lxml') badgeSet = badgeSet + badgePageData.find_all("div",{"class": "badge_title_stats"}) currentpage = currentpage + 1 except: @@ -208,7 +224,7 @@ def get_blacklist(): continue else: if authData["sort"]=="mostvalue" or authData["sort"]=="leastvalue": - gameValue = requests.get("http://api.enhancedsteam.com/market_data/average_card_price/?appid=" + str(badgeId) + "&cur=usd") + gameValue = requests.get("https://api.enhancedsteam.com/market_data/average_card_price/?appid=" + str(badgeId) + "&cur=usd") push = [badgeId, dropCountInt, float(str(gameValue.text))] badgesLeft.append(push) else: @@ -263,7 +279,7 @@ def getKey(item): logging.warning("Checking to see if " + getAppName(appID) + " has remaining card drops") rBadge = requests.get(myProfileURL + "/gamecards/" + str(appID) + "/",cookies=cookies) - indBadgeData = bs4.BeautifulSoup(rBadge.text) + indBadgeData = bs4.BeautifulSoup(rBadge.text, 'lxml') badgeLeftString = indBadgeData.find_all("span",{"class": "progress_info_bold"})[0].contents[0] if "No card drops" in badgeLeftString: logging.warning("No card drops remaining") diff --git a/Releases/Linux/steam-idle.py b/Releases/Linux/steam-idle.py old mode 100644 new mode 100755 index 68c60b7..abbf361 --- a/Releases/Linux/steam-idle.py +++ b/Releases/Linux/steam-idle.py @@ -3,17 +3,15 @@ import os import sys import platform -import io -from PIL import Image, ImageTk from ctypes import CDLL try: #Python 2 from urllib2 import urlopen except ImportError: # Python 3 from urllib.request import urlopen -try: - import Tkinter as tk -except ImportError: - import tkinter as tk + +import gtk +import gtk.gdk +import pynotify def get_steam_api(): if sys.platform.startswith('win32'): @@ -37,39 +35,34 @@ def get_steam_api(): return steam_api - -def init_gui(str_app_id): - gui = tk.Tk() - gui.title('App ' + str_app_id) - gui.resizable(0,0) - try: - url = "http://cdn.akamai.steamstatic.com/steam/apps/" + str_app_id + "/header_292x136.jpg" - image_bytes = urlopen(url).read() - data_stream = io.BytesIO(image_bytes) - pil_image = Image.open(data_stream) - tk_image = ImageTk.PhotoImage(pil_image) - label = tk.Label(gui, image=tk_image) - label.image = tk_image - except: - label = tk.Label(gui, text="Couldn't load image") - - label.pack() - return gui - if __name__ == '__main__': - if len(sys.argv) != 2: + if len(sys.argv) != 3: print("Wrong number of arguments") sys.exit() str_app_id = sys.argv[1] + str_app_name = sys.argv[2] os.environ["SteamAppId"] = str_app_id + os.environ["SteamAppName"] = str_app_name try: get_steam_api().SteamAPI_Init() except: print("Couldn't initialize Steam API") sys.exit() - gui = init_gui(str_app_id) - gui.mainloop() - \ No newline at end of file + if pynotify.init("Idle-Master"): + # Image URI + uri = "https://cdn.akamai.steamstatic.com/steam/apps/" + str_app_id + "/header_292x136.jpg" + image_bytes = urlopen(uri).read() + + loader = gtk.gdk.PixbufLoader(); + loader.write(image_bytes) + loader.close() + + n = pynotify.Notification("Now idling", "App (" + str_app_id + ") - " + str_app_name + "") + n.set_icon_from_pixbuf(loader.get_pixbuf()) + if not n.show(): + print("Failed to send notification") + else: + print("Failed to init notifications")