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

×
Simple downloader written in C++
It uses libcurl for downloading, libhtmlcxx for html parsing, libtinyxml for xml parsing, librhash for verifying md5 hashes, libjsoncpp for JSON parsing and libboost for regex and filesystem functions

You need libcurl, libhtmlcxx, libtinyxml, librhash, libjsoncpp, libboost-regex, libboost-filesystem and libboost-system for compiling
Debian/Ubuntu:sudo apt-get install build-essential libhtmlcxx-dev libcurl4-openssl-dev libtinyxml-dev librhash-dev libjsoncpp-dev libboost-regex-dev libboost-filesystem-dev libboost-system-dev
you can probably also use libcurl4-gnutls-dev or libcurl4-nss-dev if you want


0.12
Fixed login with email/password containing some special characters
Added verbose option. Useful for debugging
Changed default cookie path to ~/.gogdownloader/cookies.txt
Dropped Windows support now that GOG has new working downloader

0.12a
Some minor cosmetic changes to source code
Makefile: gogdownloader rule now depends on clean
Added license

0.12b
fixed a typo that caused batch download to ignore verbose mode

0.13
Re-use one curl handle for all operations
Fix buffer problems in cookie path caused by strcat and getenv
Makefile changes by mgol (don't make elf objs as they are unnecessary)
Use pkg-config for CFLAGS and LDFLAGS in Makefile

0.14
- Parse download details from xml files used by the official GOG Downloader (added dependency: libtinyxml)
- Get MD5 hash for downloaded files (added dependency: libcrypto++)
- Verify file integrity if xml data is available
- Verification is turned off by default. You can activate it with "-v"
- Verbose mode is now activated with "-V"

0.15
- Added repair mode

0.16
- Use getopt for command line interface
- Merged repairFile() with getFile()

0.17
- Added "--xml" to read XML data from file or create XML data for file
- Added "--xml-dir" to set path for local XML storage (default: ~/.gogdownloader/xml/)
- Try reading XML data from user specified XML file, then try remote file and finally try local file from xml-dir
- Added "--no-remote-xml" to skip trying to get XML data from GOG
- Added "--chunk-size" to use custom size for chunks when creating XML

0.18
- Rewrite some parts of code (mainly curl stuff)
- Login function now checks if login was successful

0.19
- Change progressbar in createXML to use the same progressbar as progress_callback
- Fixed bug where specifying cookie location created/updated 2 cookie files
- Fixed bug when using https urls to download single file

0.20
- Check that cookie file exists
- Silence a warning about freopen
- Changed libcrypto++ to librhash which is much smaller library
- Some small code changes to make it easier use other hash algorithms if needed in the future

0.21
- Added some comments to code
- Replaced htmlparser class with a function
- Fixed bug with filtering system that caused downloading of all links if filter didn't match anything

0.22
- Fixed downloading games from amazonaws instead of edgecastcdn
- Changed the downloader to use the shelf view (should fix the extras not showing problem)

0.23
- Make downloader work with new account page layout

0.24
- Include unistd.h : fixes compiling on Arch Linux
- Use list view to get shelf data : fixes bug with downloader not showing all games because shelf view is loaded incrementally using ajax

0.25
- Incorporated the changes by mgol
- Fixed the bug with downloader not showing all games because of ajax calls
- Some Makefile changes
- Use libjsoncpp for JSON parsing
- Show progress of getting shelf data instead of just printing dots

0.26
- Added option to limit download rate
* -L, --limit-rate <int> Limit download rate to value in kB [0 / unlimited]

0.27
- Create subdirectories for downloads
- Regular expression support for filtering (uses Perl syntax)

0.28
- Fixed login (GOG changed the login url)
- Added simple cover image download support (might not work for all games; needs better regex)
- Added "--no-cover" to skip cover image downloading

0.29
- Fixed "Unknown SSL protocol error in connection to www.gog.com:443" by using secure.gog.com

0.30
- Removed --verify as unnecessary option (--repair does practically the same job and is more useful)
- Some minor changes to regex in cover downloading
- Check for update notifications (--update-check)

0.31
- Fixed login (GOG added a parameter to login form)

https://sites.google.com/site/gogdownloader/gogdownloader-0.31.tar.gz
tar -xvzf gogdownloader-0.31.tar.gz
cd gogdownloader-0.31
make
sudo make install


Windows version 0.11: http://www.mediafire.com/?jbfbmplh1d66l3c
Attachments:
Post edited July 20, 2012 by Sude
I had some free time so I updated the downloader
It seems this isn't so simple anymore... I'm already getting confused by the source code myself :D

Source code: http://pzt.me/wo4y

Added simple resume support
- If you have a file with same name it will seek to the end of file and continues downloading
- It doesn't verify any data so it's possible to corrupt already downloaded files if the file is different (newer/older version)
Added filtering support to URL list
Added batch download support with filtering
Added command line interface

Todo:
Implement login to automatically create cookies.txt

Usage:
./GOGDownloader [-h] [-s] [-b] [-f string] [-l] [-d path] [-c file] URL
-h Show help
-s Show URLs
-b Batch download, use -f to filter
-f string Filter - show/download URLs containing "string" [""]
-l Login (not implemented)
-d path Download directory [""]
(with trailing slash; directory must exist)
-c file Path to cookies ["cookies.txt"]

Batch download example:
- downloading Tyrian 2000 files
- setup_tyrian_2000.exe - already downloaded previously
- tyrian2000_ost.zip - incomplete - 46.45MB already downloaded previously

sude@MintDebian ~ $ ./GOGDownloader -b -f tyrian
Starting batch download
Downloading: setup_tyrian_2000.exe
0% [ ] 0.00/0.00MB 0.00kB/ss
Downloading: tyrian2000_ost.zip
100% [========================================] 79.85/79.85MB 1297.89kB/s
Batch download finished
Is this for Linux systems or would it work on OSX/Windows too? (theoretically, even if you haven't tested it yourself - like you haven't with Windows but you seem to imply it would theoretically work there too)
Post edited March 05, 2011 by crazy_dave
avatar
crazy_dave: Is this for Linux systems or would it work on OSX/Windows too? (theoretically, even if you haven't tested it yourself - like you haven't with Windows but you seem to imply it would theoretically work there too)
It should be possible to compile this on Windows and OSX as both libraries used (curl and htmlcxx) support them

edit: managed to compile it on Windows but for some reason CURLINFO_REDIRECT_URL returns garbage :(
Post edited March 05, 2011 by Sude
Tried to cross-compile with mingw32 from Linux
- Higher ASCII characters in URLs didn't work (for example King's Bounty)
- It was able to get filename when running with wine but not on Windows where it returned corrupted data

So I tried mingw32 compile from Windows host but it had the same problems

So it was time to install Cygwin and test if I'd have better luck with it
and it was a success! :)

Windows version: http://www.mediafire.com/?mdhba391baaaqz1
now with login function
./GOGDownloader -l

It doesn't check if login was successful
try to get URL list with ./GOGDownloader -s
if you get list of URLs then login was successful otherwise try again

Source code: http://pzt.me/aozf
Windows version: http://www.mediafire.com/?jbfbmplh1d66l3c
0.12

Fixed login with email/password containing some special characters
Added verbose option. Useful for debugging
Changed default cookie path to ~/.gogdownloader/cookies.txt
Dropped Windows support now that GOG has new working downloader

http://sites.google.com/site/gogdownloader/gogdownloader-0.12.tar.gz
tar -xvzf gogdownloader-0.12.tar.gz
make
sudo make install
This looks great - I'm very much liking the minimal implementation.
Post edited May 14, 2011 by asb
I tried to compile it on ubuntu 9.10 and it didn't work out. First, libhtmlcxx is not available as a package. I downloaded and installed it. No issues. Compilation of gogdownloader goes well but at run time it returns:

./gogdownloader: error while loading shared libraries: libhtmlcxx.so.3: cannot open shared object file: No such file or directory

However, using dpkg -L htmlcxx reveals (among others):
/usr/local/lib/libhtmlcxx.so.3.1.0
/usr/local/lib/libhtmlcxx.so
/usr/local/lib/libhtmlcxx.so.3

I tried to add the flag -L/usr/local/lib in the makefile but it is not working.
LDFLAGS=-L/usr/local/lib -lcurl -lhtmlcxx

This, does work:
LD_LIBRARY_PATH=/usr/local/lib ./gogdownloader -h

Of course, I would prefer to fix the Makefile. Suggestions?
avatar
fmartins: I tried to compile it on ubuntu 9.10 and it didn't work out. First, libhtmlcxx is not available as a package. I downloaded and installed it. No issues. Compilation of gogdownloader goes well but at run time it returns:

./gogdownloader: error while loading shared libraries: libhtmlcxx.so.3: cannot open shared object file: No such file or directory

However, using dpkg -L htmlcxx reveals (among others):
/usr/local/lib/libhtmlcxx.so.3.1.0
/usr/local/lib/libhtmlcxx.so
/usr/local/lib/libhtmlcxx.so.3

I tried to add the flag -L/usr/local/lib in the makefile but it is not working.
LDFLAGS=-L/usr/local/lib -lcurl -lhtmlcxx

This, does work:
LD_LIBRARY_PATH=/usr/local/lib ./gogdownloader -h

Of course, I would prefer to fix the Makefile. Suggestions?
That's weird, adding -L/usr/local/lib should be the solution for that

Lets make sure the system knows about the library by updating links and cache
sudo ldconfig

Try using this
LDFLAGS=-Wl,-rpath,/usr/local/lib -lcurl -lhtmlcxx

if that fails you could install libhtmlcxx to /usr/lib by setting the prefix in configure
./configure --prefix=/usr
sorry, -L works, I had forgotten to make clean.

BTW, I used it to download The Witcher (1) and it all went very smooth and fast!

Many thanks for the util!

Cheers
avatar
Sude: If you know C/C++ feel free to implement more features and fix bugs
Currently it doesn't do any error checking and I haven't tested if it compiles on Windows
All downloads are saved to current working directory
cookies.txt (Netscape format) containing your GOG cookies must be in current working directory
I was wondering if you could state a license for the project? Personally I'm a fan of the MIT license, but whatever floats your boat.
Post edited May 14, 2011 by asb
avatar
asb: I was wondering if you could state a license for the project? Personally I'm a fan of the MIT license, but whatever floats your boat.
I quite like the WTFPL license

0.12a
Some minor cosmetic changes to source code
Makefile: gogdownloader rule now depends on clean
Added license

http://sites.google.com/site/gogdownloader/gogdownloader-0.12a.tar.gz


0.12b
fixed a typo that caused batch download to ignore verbose mode

http://sites.google.com/site/gogdownloader/gogdownloader-0.12b.tar.gz
Post edited May 18, 2011 by Sude
0.13
Re-use one curl handle for all operations
Fix buffer problems in cookie path caused by strcat and getenv
Makefile changes by mgol (don't make elf objs as they are unnecessary)
Use pkg-config for CFLAGS and LDFLAGS in Makefile

http://sites.google.com/site/gogdownloader/gogdownloader-0.13.tar.gz
0.14
- Parse download details from xml files used by the official GOG Downloader (added dependency: libtinyxml)
- Get MD5 hash for downloaded files (added dependency: libcrypto++)
- Verify file integrity if xml data is available
- Verification is turned off by default. You can activate it with "-v"
- Verbose mode is now activated with "-V"

https://sites.google.com/site/gogdownloader/gogdownloader-0.14.tar.gz


Originally I was going to use librhash for getting md5 but apparently packages are not yet available in some distributions (Ubuntu) so I used libcrypto++ which is much bigger library
Here's a diff you can apply if you want to use librhash
wget https://sites.google.com/site/gogdownloader/rhash.diff
patch -p0 < rhash.diff


Another diff to get offsets and md5 hashes for all chunks from xml file
wget https://sites.google.com/site/gogdownloader/chunk-info.diff
patch -p0 < chunk-info.diff

Chunk info isn't used anywhere at the moment but it could be used to implement a repair mode where the program would repair corrupted files by comparing md5 hashes of the chunks and then downloading the corrupted chunks again
Another use for this info could be multithreaded downloading using pthreads or curl multi interface
Post edited June 28, 2011 by Sude