It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

×
avatar
phaolo: Anyway, I got a crash after many hours, due to a failed connection:

sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I found a similar error during the night. That can be caused by a number of things, such as:
- Internet connection failing (there was a big thunderstorm here yesterday, and I lost connection for a while);
- GOG's server not responding on time; or
- Something else that I think may be more unlikely than the previous situations.

I may try to handle those situations more gracefully. Maybe spitting out error messages and keep insisting indefinitely, instead of exiting with that notice.
avatar
mchack: thank you for this :) this helped me get my beep going aswell I tried "sudo /usr/bin/beep" but it has to be "usr/bin/sudo","/usr/bin/beep" aparrently ;)
You could run "chmod a+s /usr/bin/beep" to set the "set user id" flag on the file's permissions. This allows any user to run beep. It seems unlikely that this can be exploitable from a security point of view.
avatar
Gede: Beep does not come "as standard" with Linux. It is usually some package that needs to be added. I don't know why, since my shell has no trouble beeping at me. :-)
Indeed I had to install beep, it was not installed by default (not that surprising, considering I'm running heavily tweaked gentoo and there are very few packages that I didnt ask portage to install). What I mean is that it doesn't work even after I installed it and tested as root. I could probably expose PC speaker in VM configuration, this was just quicker than rebooting the machine and starting all the running stuff again.

avatar
Gede: Your suggestion is accepted, and I will move the configuration into its own file. That may allow me to provide more configuration options. I'm sorry for the trouble it caused you.
Not a trouble for me, as a dev I deal with version control and diff all the time, I just never felt the need to learn Python, so my mplayer solution is pretty hacky. Just few lines below there is example of how to get rid of stderr "the Python way" I should have copied. Thanks for considering it, It should help some people.
the script is still crashing for me whenever a bundle appears .... any way to circumvent that?

Traceback (most recent call last):
File "./the_napping_gamer.py", line 498, in <module>
wait_time = max(min(sleep_time, check_games()), minimum_sleep_value)
File "./the_napping_gamer.py", line 432, in check_games
for game_info in extract_game_data(read_from_url(url)):
File "./the_napping_gamer.py", line 368, in extract_game_data
for product_id in data["bundle"][productIds]:
NameError: name 'productIds' is not defined
avatar
mchack: the script is still crashing for me whenever a bundle appears .... any way to circumvent that?
You are not running the latest version. I fixed that silly bug yesterday.
I uploaded a new version to GitHub just now, that shows the pretty titles.

Try out this version. It should run without any huckup.
Post edited March 22, 2016 by Gede
avatar
mchack: the script is still crashing for me whenever a bundle appears .... any way to circumvent that?
avatar
Gede: You are not running the latest version. I fixed that silly bug yesterday.
I uploaded a new version to GitHub just now, that shows the pretty titles.

Try out this version. It should run without any huckup.
oh, sorry I must've missed that. Yep works great now :D Thanks!
There's another little bug.
The script doesn't like something in the Oddword game title:

return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2122' in position
30: character maps to <undefined>

Also, I still have to change my working dir.
Post edited March 23, 2016 by phaolo
avatar
phaolo: Another little bug (maybe for a strange game title?):
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2122' in position
30: character maps to <undefined>

Also, I still have to change my working dir.
I find that odd and unexpected. It is complaining about the ™ symbol. I wonder if it is a font issue?
I wish there was a GOGmix for "Games with ™ in their title". Was it "The Last Tinker?"

Anyway, here is a "hotfix" for you: go to line 395, and add a new line before it (between the line that starts with "raise ValueError" and the line that goes "return [{" ) saying:

game_title = game_title.replace("\u2122","")

Make sure that the new line you entered has two spaces before the text, so that it matches the indentation of the line that follows it (the one that starts with "return").
This will remove the offending character from the game's title, and should prevent future similar errors. (At least The Dig® did not cause any problems :-).

Edit:
Regarding your work directory, in line 88 you can specify the full path to your wishlist file. Like this:

wishlist_file = r"c:\Program Files\GOG\Insomnia\wishlist.txt"
Post edited March 23, 2016 by Gede
avatar
Gede: Anyway, here is a "hotfix" for you
Cool fixes on the fly, thanks ;)
Weird python path conversion btw (r?)
avatar
phaolo: Cool fixes on the fly, thanks ;)
Weird python path conversion btw (r?)
The "r" string literal prevents the \ character from being interpreted as an escape character.
You could use a regular string if you type the path using the / character as the directory separator. Windows understands both / and \ paths since... 2000? XP?

I did wonder if you would notice the "r". But I figured it would be easier to add it and allow you to copy/paste the path, than telling you to escape or change the slashes in the path.
avatar
Gede: The "r" string literal prevents the \ character from being interpreted as an escape character.
I see, thanks for the explanation.
Pasting paths directly is way better.

--

Anyway, new bug.
Maybe I'll try replacing this character too:

return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\xae' in position 37
: character maps to <undefined>

--

Another one :\

\u2019

--

And then Gog fed up lol:

raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10054] An existing connection wa
s forcibly closed by the remote host>
Post edited March 23, 2016 by phaolo
Why doesn't 'firefox' work on my system? I had to use 'windows-default'.
avatar
Starmaker: Why doesn't 'firefox' work on my system? I had to use 'windows-default'.
my browser "google-chrome-stable" didn't work either, but I don't need the browser open feature, since it's open anyway so no prob for me ;)

---

Hehe, just a funny moment reading the log, when I got back to my laptop:

11:44:51 "Lords of Xulima" USD 7.99 1/25 expected sale time: 0.4 min (11:45:15))
You may nap for 0.4 more minutes (11:45:15). I'll stand guard! Next peek in 24 seconds.
11:45:15 "Monkey Island Classics (Monkey Island 1 & 2 Special Editions)" USD 3.98 5/50 expected sale time: 317.8 min (17:03:05))
You may nap for 317.8 more minutes (17:03:04). I'll stand guard! Next peek in 30 seconds.
12:45:46 NEW! "I Have No Mouth And I Must Scream" at USD 1.49 (-75%) 23/25 copies ('https://www.gog.com//game/i_have_no_mouth_and_i_must_scream',)

lol, oh btw, anyone know how/if I could bold the title of the game in the output of the script?
Post edited March 23, 2016 by mchack
avatar
mchack: Hehe, just a funny moment reading the log, when I got back to my laptop:
...
lol, oh btw, anyone know how/if I could bold the title of the game in the output of the script?
Yep, there are some bugs in the script. I just got an estimate for the D&D bundle with EST of 810 mins, then 147 mins, and then it was predictably gone. (And The War of Mine, which is the other repeat since I started watching. Repeat estimates are broken.)
Also, from looking at the data, the first estimate should be at least halved and generally treated with suspicion.

(This is not to be construed to detract from Gede's great work.)

edit: the US has truly awakened. Good thing I modded the script to only alert me on new appearances of games.

edit 2, on bolding game names: it depends on what you're using for output. I use the IDLE shell and I'm not sure if it even has text styles.

edit 3: the alert doesn't go off for bundles for some reason.
Post edited March 23, 2016 by Starmaker
I'm having weird amount of fun while tinkering with this script, thanks again to Gede (and sorry windows folks, I'm not going to learn how to do all that in python - perl, bash and bunch of linux commandline utilities is what you get).

First, you have to log TNP output. -u is needed otherwise output will be buffered and you only get notification after 4096 bytes of output accumulate, which is far too late:
while true; do python3 -u ./the_napping_gamer.py 2>&1 | tee -a the_napping_gamer.log; if ! sleep 10; then break; fi; done

If you want to know what games are part of insomnia, or what exactly to put into your wishlist.txt (should you include ":" or not etc.):
cat the_napping_gamer.log | perl -n -e'if (m/NEW! "(.*)"/) { print "$1\n"; }' | sort | uniq

You can also redirect output of above commands to a file, say "list_snapshot", let it run for a while and then see what new games GOG added to the insomnia since then:
cat the_napping_gamer.log | perl -n -e'if (m/NEW! "(.*)"/) { print "$1\n"; }' | sort | uniq | cat - list_snapshot | sort | uniq -u

And finally, if you want to know how much money GOG got from insomnia (only estimate - because regional prices, nobody probably has the complete log, and the log will contain duplicates around restarts/crashes):
#!/usr/bin/env perl

my $totalPrice = 0;
my $totalItems = 0;
my $lastGame = '';

while ($_ = <STDIN>) {
if (m#\d{2,2}:\d{2,2}:\d{2,2}\s*"([^"]*)"\s*[A-Z]{3,3}\s*([0-9.]*)\s*\d+/(\d+)#) {
if ($1 ne $lastGame) {
$lastGame = $1;
$totalItems += $3;
$totalPrice += ($3 * $2);
}
}
}
printf "total sales: $totalItems for $totalPrice \$, average %.2f\n", ($totalPrice / $totalItems);

Also, a small bug:
16:51:51 NEW! "reus" at USD 1.99 (-80%) 16/25 copies ('https://www.gog.com//game/reus',)
15:51:51 "reus" USD 1.99 16/25
You may nap for 0.8 more minutes (15:52:39). I'll stand guard! Next peek in 30 seconds.
The first timestamp respects my UTC offset, second does not.

EDIT: bug in sale summary script
Post edited March 24, 2016 by huan