Coder Social home page Coder Social logo

packt-cli / packt-publishing-free-learning Goto Github PK

View Code? Open in Web Editor NEW
855.0 55.0 185.0 262 KB

Scripts that automatically claim and download free daily eBooks from https://www.packtpub.com/packt/offers/free-learning

License: MIT License

Python 100.00%
packtpub ebook free-ebook python google-drive anti-captcha

packt-publishing-free-learning's Introduction

Version Python Versions lint

Free Learning Packt Publishing script

packt-cli is a Python script that allows to automatically grab and download a daily Free Learning Packt ebook from https://www.packtpub.com/packt/offers/free-learning. You can also use it to download already claimed ebooks from your Packt account.

The script uses anti-captcha.com service to bypass the Recaptcha captcha to function fully automatically. Anti Captcha employs people to solve captcha tests. The service costs about $2 per thousand captcha test, allowing you to operate for a few dollars over the years.

Installation

To install current version of script simply run

pip3 install packt --upgrade

You may want to install it inside new virtualenv.

Usage

The packt-cli script might be executed with several optional arguments.

  • Option -g [--grab] - claims (grabs) a daily eBook into your account
packt-cli -g
  • Option -gd [--grabd] - claims (grabs) a daily ebook and downloads the title afterwards to the location specified under [download_folder_path] field (configFile.cfg file)
packt-cli -gd
  • Option -da [--dall] - downloads all ebooks from your account
packt-cli -da
  • Option -sgd [--sgd] - claims and uploads a book to [gdFolderName] folder onto Google Drive (more about that in Google Drive API Setup section)
packt-cli -sgd
  • Option -m [--mail] - claims and sends an email with the newest book in PDF format (and MOBI if is also downloaded; see mail options confguration under [MAIL] path in configFile.cfg)
packt-cli -m
  • SubOption -sm [--status_mail] - sends fail report email whether script execution was successful
packt-cli -gd -sm
  • SubOption -f [--folder] - downloads an ebook into a created folder, named as ebook's title
packt-cli -gd -f
  • SubOption -c [--cfgpath] - selects folder where config file can be found (default: cwd)
packt-cli -gd -c /home/usr/

Example

Download all ebooks in all available formats (pdf, epub, mobi) with zipped source code file from your Packt account.

To download all ebooks in all available formats from your Packt account, you have to prepare your config file as shown below:

[LOGIN_DATA]
email: [email protected]
password: yourpassword

[DOWNLOAD_DATA]
download_folder_path: C:\Users\me\Desktop\myEbooksFromPackt
download_formats: pdf, epub, mobi, code

[GOOGLE_DRIVE_DATA]
gd_app_name: GoogleDriveManager
gd_folder_name: PACKT_EBOOKS

run:

  packt-cli -da

Scheduled script execution setup

Debian

On Debian (and any Debian-based Linux distribution) you may use cron job to schedule script execution. To do this run crontab -e and add the following line to crontab file.

0 12 * * * path/to/virtualenv/bin/packt-cli -gd > path/to/log/file 2>&1

Adjust execution time and paths according to your setup. To verify if cron executes the script as expected, run

$ sudo grep CRON /var/log/syslog

Windows

schtasks.exe setup (more info: https://technet.microsoft.com/en-us/library/cc725744.aspx) :

To create the task that will be called at 12:00 everyday, run the following command in cmd (modify all paths according to your setup):

schtasks /create /sc DAILY /tn "grabEbookFromPacktTask" /tr "C:\Users\me\Desktop\GrabPacktFreeBook\grabEbookFromPacktTask.bat" /st 12:00

To check if the "grabEbookFromPacktTask" has been added to all scheduled tasks on your computer:

schtasks /query

To run the task manually:

schtasks /run /tn "grabEbookFromPacktTask"

To delete the task:

schtasks /delete /tn "grabEbookFromPacktTask"

If you want to log all downloads add -l switch to grabEbookFromPacktTask i.e.

schtasks /create /sc DAILY /tn "grabEbookFromPacktTask" /tr "C:\Users\me\Desktop\GrabPacktFreeBook\grabEbookFromPacktTask.bat -l" /st 12:00

If you want to additionaly make command line windows stay open after download add -p switch i.e.

schtasks /create /sc DAILY /tn "grabEbookFromPacktTask" /tr "C:\Users\me\Desktop\GrabPacktFreeBook\grabEbookFromPacktTask.bat -l -p" /st 12:00

Google Drive API Setup

Full info about the Google Drive Python API can be found here.

  1. Turn on the Google Drive API
  • Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
  • On the Add credentials to your project page, click the Cancel button.
  • At the top of the page, select the OAuth consent screen tab. Select an email address, enter a product name if not already set, and click the Save button.
  • Select the Credentials tab, click the Create credentials button and select OAuth client ID.
  • Select the application type Other, enter the name GoogleDriveManager, and click the Create button.
  • Click OK to dismiss the resulting dialog.
  • Click the file_download (Download JSON) button to the right of the client ID.
  • Move this file next to the config file and rename it to client_secret.json.
  1. Create credentials folder:
  • Simply, just fire up the script with -sgd argument; During first launch you will see a prompt in your browser asking for permissions, click then allow
packt-cli -sgd
  • Or if you're unable to launch browser locally (e.g. you're connecting through SSH without X11 forwarding) use this command once, follow instructions and give permission and later you can use normal command (without --noauth_local_webserver).
packt-cli -c /path/to/config/file.cfg -sgd --noauth_local_webserver

The command parameters number and their order is important!

  1. Already done!
  • Run the same command as above to claim and upload the eBook to Google Drive.

In case of any questions feel free to ask, happy grabbing!

packt-publishing-free-learning's People

Contributors

ad-m avatar awegmann avatar biomadeira avatar brunifrancesco avatar d3m3vilurr avatar dependabot[bot] avatar djvdorp avatar eugenesia avatar int0x80 avatar josevill avatar kuldazbraslav avatar laurentlemercier avatar luk6xff avatar mjenczmyk avatar quizr avatar timothydjones avatar trancen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packt-publishing-free-learning's Issues

[ERROR] - Exception occurred 'NoneType' object is not subscriptable

Hi,

I have such error for 2 days:

[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Start grabbing eBook...
[ERROR] - Exception occurred 'NoneType' object is not subscriptable

Looks like they changed GUI a little. Sorry but I didn't find time right now to debug it further.

windows line endings in `packtPublishingFreeEbook.py`

The python file is contaminated with windows line endings. As a result, if you execute this file directly (via the shebang), an error occurs since the shell can't find "python\r". The line endings can be converted (eg. with dos2unix), but that puts the repo out-of-sync. It's not a problem if you execute with python packtPublishingFreeEbook.py.

to reproduce: On unix, clone repository and execute:

cd Packt-Publishing-Free-Learning
chmod a+x packtPublishingFreeEbook.py
./packtPublishingFreeEbook.py

exprected result: script should run, outputting [INFO] - Creating session... , etc.
actual result: script aborts with error: /usr/bin/env: ‘python\r’: No such file or directory

upload already downloaded files to google drive

Is it possible to upload the already downloaded files/folders to google drive in a way that the folder structure of the google drive upload folder would be the same as the structure of the download_folder_path?

"ImportError: No module named configparser" error on Python 2.7.13

I've added one task to launchd on Mac and during executing it I have an error which provided below:

Traceback (most recent call last):
  File "/Users/develsites/packt_grabber/src/packtPublishingFreeEbook.py", line 10, in <module>
    import configparser
ImportError: No module named configparser

If I run the script inside in the src folder directly in terminal then it works correctly.

How to solve this issue? Thanks

Error no module named requests

RaspberryPi3 -all upgraded, Python 3.6.0
When firedup from crontab I get this:
packtPublishingFreeEbook.log:

  File "packtPublishingFreeEbook.py", line 13, in <module>
    import requests
ImportError: No module named 'requests' 

I maked venv for packtpub and installed inside venv all from file requirements.txt

pip3 install requests==2.18.4
Requirement already satisfied: requests==2.18.4 in /home/pi/packtpub/lib/python3.6/site-packages```

Some unicode crap in book title generates error

Hi again,

thanks god they enabled free ebooks again! :)

Today's one Kali Linux – Assuring Security by Penetration Testing have strange unicode dash that generates error:

[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Start grabbing eBook...
[INFO] - Getting data of all your books...
[INFO] - Opened 'https://www.packtpub.com/account/my-ebooks' successfully!
[INFO] - Title: 'Kali Linux   Assuring Security by Penetration Testing'
[INFO] - Downloading eBook: 'Kali Linux   Assuring Security by Penetration Testing' in .pdf format...
[PROGRESS] - [################################################# ] 100.0% [SUCCESS] - eBook: 'Kali Linux   Assuring Security by Penetration Testing.pdf' downloaded successfully!
[INFO] - Title: 'Kali Linux   Assuring Security by Penetration Testing'
[INFO] - Downloading eBook: 'Kali Linux   Assuring Security by Penetration Testing' in .mobi format...
[PROGRESS] - [################################################# ] 100.0% [SUCCESS] - eBook: 'Kali Linux   Assuring Security by Penetration Testing.mobi' downloaded successfully!
[INFO] - 2 eBooks have been downloaded!
[SUCCESS] - Good, looks like all went well! :-)
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 980, in emit
    stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2013' in position 68: ordinal not in range(128)
Call stack:
  File "/opt/ppfl/packtPublishingFreeEbook.py", line 331, in <module>
    grabber.grabEbook()
  File "/opt/ppfl/packtPublishingFreeEbook.py", line 176, in grabEbook
    logger.success("eBook: '{}' has been successfully grabbed!".format(self.bookTitle))
  File "/opt/ppfl/utils/logger.py", line 16, in <lambda>
    logger.success = lambda msg, *args: logger._log(logging.SUCCESS, msg, args)
Message: "eBook: 'Kali Linux \u2013 Assuring Security by Penetration Testing' has been successfully grabbed!"
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 980, in emit
    stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2013' in position 31: ordinal not in range(128)
Call stack:
  File "/opt/ppfl/packtPublishingFreeEbook.py", line 331, in <module>
    grabber.grabEbook()
  File "/opt/ppfl/packtPublishingFreeEbook.py", line 176, in grabEbook
    logger.success("eBook: '{}' has been successfully grabbed!".format(self.bookTitle))
  File "/opt/ppfl/utils/logger.py", line 16, in <lambda>
    logger.success = lambda msg, *args: logger._log(logging.SUCCESS, msg, args)
Message: "eBook: 'Kali Linux \u2013 Assuring Security by Penetration Testing' has been successfully grabbed!"
Arguments: ()

If this happens once, it will happen again in future.

Ebook was grabbed and downloaded successfully but with filename without unicode sign:

Kali Linux   Assuring Security by Penetration Testing.mobi

Running on docker containers

First of all, thanks for your code it works fine on my localhost but I've got something strange when moving your code in a docker container on a KVM VM.
So I have a small VM from Lunanode in Roubaix and set up a docker container using a docker build with all your code on python3.4.
All is good till I got a trouble in line 177 of your Pack py program. I have a 404 error but I don't why the beautifulsoup parser find the downloaded url but failed afterwards for some reason but all works on my localhost. Did I miss something when moving to a container?
Thanks

Need switch to disable progress bar

If the code is done daily by cron, it ends up generating 2+ meg of log just from a single book download from the update of the progress bar.

The progress bar should only be output if it is run in an interactive shell, and there should probably be a command line switch or config option to disable the progress bar to avoid generating tons of useless logging data.

[Error] - Exception occurred Incorrect file paths argument format

[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Start grabbing eBook...
[INFO] - Captcha detected. Trying to solve it using anti-captcha.com.
[INFO] - TaskId created: 467626809
[INFO] - Waiting for completion of the task: 467626809...
[SUCCESS] - Solution found for task: 467626809
[SUCCESS] - eBook: 'AWS_Administration_-_The_Definitive_Guide' has been successfully grabbed!
[INFO] - Getting data of all your books...
[INFO] - Opened 'https://www.packtpub.com/account/my-ebooks' successfully!
[INFO] - There is no books with provided titles: [u'AWS_Administration_-_The_Definitive_Guide'] at your account!
[INFO] - 0 eBooks have been downloaded!
[ERROR] - Exception occurred Incorrect file paths argument format

Having this issue while executing the script with command python packtPublishingFreeEbook.py -sgd.

Anybody can help on this?

Error at exit

After grab and download book program doesn't exit clean.

[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Start grabbing eBook...
[SUCCESS] - eBook: 'OpenCV_for_Secret_Agents' has been successfully grabbed!
[INFO] - Getting data of all your books...
[INFO] - Opened 'https://www.packtpub.com/account/my-ebooks' successfully!
[INFO] - Title: 'OpenCV_for_Secret_Agents'
[INFO] - Downloading eBook: 'OpenCV_for_Secret_Agents' in .pdf format...
[SUCCESS] - eBook: 'OpenCV_for_Secret_Agents.pdf' downloaded successfully!
[INFO] - Title: 'OpenCV_for_Secret_Agents'
[INFO] - Downloading eBook: 'OpenCV_for_Secret_Agents' in .epub format...
[SUCCESS] - eBook: 'OpenCV_for_Secret_Agents.epub' downloaded successfully!
[INFO] - Title: 'OpenCV_for_Secret_Agents'
[INFO] - Downloading code for eBook: 'OpenCV_for_Secret_Agents'...
Traceback (most recent call last):
File "packtPublishingFreeEbook.py", line 345, in
downloader.downloadBooks([grabber.bookTitle], intoFolder = intoFolder)
File "packtPublishingFreeEbook.py", line 275, in downloadBooks
for num, chunk in enumerate(r.iter_content(chunk_size=1024)):
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 719, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/response.py", line 432, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/response.py", line 380, in read
data = self._fp.read(amt)
File "/usr/lib/python2.7/httplib.py", line 573, in read
s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read
data = self._sock.recv(left)
KeyboardInterrupt

usage with Anaconda

I uninstalled pure Python on my Windows system and switched to use Anaconda. How should I install this script and its requirements? conda or pip? I created a new environment for just this script but don't know / can't decide what to do now. Can someone add some help to instructions on installing this under Anaconda please?

'flush' error when using Python 2 from the progress bar

[ERROR] - 'flush' is an invalid keyword argument for this function

I believe it's because Python 2 doesn't support the use of 'flush=true' as it's a feature starting from Python 3.3 from what I gather.
Line 215 from :
print("\r[PROGRESS] - [{0:50s}] {1:.1f}% ".format('#' * int(currentWorkDone * 50), currentWorkDone*100), end="", **flush=True**)
Alternative to this would be to 'import sys' and then to flush it manually in a separate line:
sys.stdout.flush()

Doesn't affect the functionality of the script itself but the progress bar will not be shown when using Python 2. It seems like the above is also supported in Python3, obviously not as nice as having it as an argument to print() though.
Btw love the script, nice work on it 👍

Lint the code with pylama

As code in this repo is becoming more and more compliant with PEP8 it would be nice to use pylama to lint it - it's easy to configure Travis to run pylama on every PR and warn about style issues in PR changes. Existing and harder to resolve issues could be ignored in pylama configuration and resolved later.

To be done:

  • use pylint linter;
  • use mccabe linter;
  • use pycodestyle linter;
  • use pyflakes linter;
  • use pydocstyle linter;
  • configure Travis task;

Email notifications should allow sending email without login/password and/or TLS

When trying to send an email using localhost or another "internal" mail server, it fails:

Traceback (most recent call last):
  File "src/packtPublishingFreeEbook.py", line 408, in <module>
    mb = MailBook(cfg_file_path)
  File "<removed>/prg/Packt-Publishing-Free-Learning/src/utils/mail.py", line 29, in __init__
    self._email_pass = config.get("MAIL", 'password')
  File "/usr/lib/python2.7/ConfigParser.py", line 618, in get
    raise NoOptionError(option, section)
ConfigCarser.NoOptionError: No option 'password' in section: 'MAIL'

(Note that I've hacked the script to use ConfigParser since I have an older version of Python installed)

Also, the email fails if the given server doesn't support TLS (which isn't needed if the server is local/private):

[ERROR] - Sending failed with an error: STARTTLS extension not supported by server.

error in login to google Drive

It present error that the credetial directory doesnt exist. Furthermore it required verification which I also dont know...

/usr/local/lib/python2.7/dist-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /home/admin/Packt/.credentials/GoogleDriveManager.json: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))

Download the last one, two or X claimed books

Hello,
While the option to automatically grab a book is not available right now (Captcha), please consider include option to download the last X books from the all books list.
The is an option to download all books. The latest claimed books are at the top of the list, so it should be easy to just pick the one, two or X last claimed books.
It will do some of the work, while I have to manually claim the book, I could run the script to automatically download it and move to some directory / send to google.

Best Regards
Y

Drop Python 2.6 support

Last Python 2.6 release was in 2008. Could we drop the support for it and remove redundant code?

Error: eBook: Book_Name has not been grabbed!, does this promo exist yet? visit the page and check!

[ERROR] - eBook: Building_Machine_Learning_Projects_with_TensorFlow has not been grabbed!, does this promo exist yet? visit the page and check!
[ERROR] - Exception occurred eBook: Building_Machine_Learning_Projects_with_TensorFlow has not been grabbed!, does this promo exist yet? visit the page and check!

Did someone already faced this error?

EDIT: Ok, I guess the captcha did take too long to execute, so the script tried to grab an ebook at 00:01 where it already was replaced by a new one.

problem with attribute

During excecutions python packtPublishingFreeEbook.py -da
[INFO] - Creates session ...
[INFO] - Session created, logged succesfully!
[INFO] - Getting data of all your books...
[INFO] - opened 'https://www.packtpub.com/account/my-ebooks' succesfully!
[ERROR] - Exception occured 'NoneType' object has no attribute 'find_all'

Split status mail flag with success and failure

Actually the script is very spamer sending all the correct fetched books, when I only want to see if an error happened, like before with -rm

Can you recover this funcionality? for example, with 2 flags one OK, other for Failure (and the actual that enables both)

Exception occurred Some of the required values for successive user emulation are missing

Just logged into my server and noticed the script couldn't claim an ebook since october 20th.

[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Start grabbing eBook...
[INFO] - Captcha detected. Trying to solve it using Anti-captcha.com.
[ERROR] - Exception occurred Some of the required values for successive user emulation are missing.. Website stoken is invalid. Expected string value, received array

Does someone know how to solve this? Am I the only one facing this issue?

Abbility to download the Info and Cover Of the Book

I tried putting the argument of downloading the cover and info, but the script ignores it.
This is how my download data looks:

[DOWNLOAD_DATA]
download_folder_path: C:\Users\kunal\Downloads\Compressed\PAckt
download_formats: pdf, epub, mobi, cover, code, info
download_book_titles: Unity 4.x Game AI Programming , Multithreading in C# 5.0 Cookbook
ebook_extra_info_log_file_path: eBookMetadata.log

Do we still need bat script when there is PowerShell?

Is the bat script still needed? As for now all supported Windows systems allow useds to use PowerShell, so maybe this bat script is obsolete and may be removed? I'm assuming that script usage on Windows does not differ from usage on Debian (with the exception of cron tasks on Debian vs schtasks on Windows).

Sorry if I'm writing something that is false; I don't use Windows anymore - in that case correct me.

Seems like hanged on big downloads

Download seems hanged or timeout when a big file downloads e.g. last weeks "Blender 2.5 Materials and Textures Cookbook" title's code file which was a couple of hundredths MB in size! I waited for hours for it to complete, there was no disk activity for a long time so I finally pressed Ctrl-C to end the script. Luckily the file was fully downloaded but somehow script hanged there. After my Ctrl-C, the script continued processing other files. I think there should be a progress indicator for displaying how much of a file is downloaded, either a percentage or raw bytes.

Website stoken 'Array' is invalid.!

Grabber is failing for 4 easy with the message below, no change in my environment, maybe in packt's:

Today's free Packt ebook grabbing has failed with exception: Some of the required values for successive user emulation are missing.. Website stoken 'Array' is invalid.!

feature request: specify logfile (for logging output)

Hi again, practical thing ... it seems that the standard log option writes this to the specified logfile (in config):

TITLE --> Python Unlocked
DESCRIPTION --> Become more fluent in Python—learn strategies and techniques for smart and high-performance Python programming
AUTHOR --> Arun Tigeraniya
TIME --> 2015-12-30
DOWNLOADED_AT --> 15-10-2016 02:21

the logging module output however is more verbose / useful info, but goes to console only:

[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Start grabbing eBook...
..
..

So when using this script I added "filename=.. " to the basicConfig of logging:

logging.basicConfig(format='[%(levelname)s] - %(message)s', filename='logfile.log', level=logging.INFO)

Maybe this can be feature can be added to config / cli switches? I found it not that straight-forward though as this happens at the toplevel of the module, yet the reading of config variables happens in the PacktAccountData class.

thanks

Download list of all ebook on account

Hi! There are some possibilities that you can implement a way to download a complete .txt list wit all e-books inside the logged account?

Thanks in advance

videos

hi
first of all thanks for making this program
can you tell me we can download packt publishing videos also from this downloader ?

[ERROR] - Exception occurred u'href'

This error started happening today when trying to grab the current ebook. Checked the site, and it seems they've implemented captcha. Not sure how long they've had this, but I think it's the first time I've seen it. Guessing the captcha is what's causing the error. Downloading existing books on my account still seems to work fine.

Some of the required values for successive user emulation are missing.. Website stoken 'Array' is invalid.

2017-10-30 15:14:57,693 - main - [INFO] - Creating session...
2017-10-30 15:15:09,581 - main - [INFO] - Creating session...
2017-10-30 15:15:14,766 - main - [INFO] - Session created, logged in successfully!
2017-10-30 15:15:14,768 - main - [INFO] - Start grabbing eBook...
2017-10-30 15:15:15,022 - main - [INFO] - Captcha detected. Trying to solve it using Anti-captcha.com.
2017-10-30 15:15:15,575 - main - [ERROR] - Exception occurred Some of the required values for successive user emulation are missing.. Website stoken 'Array' is invalid.

apiclient has no http module

When i try to import from apiclient.http i get ImportError. That's what we do in Google Drive module. I guess we should import from Google API Python Client, but I started to wonder if Google Drive integration was ever working? @igbt6, have you ever used it?

I can make a pull request to use Google API Python Client, but I won't be able to see if entire functionality works (I don't use Google services). Should I make a pull request in that case? Will anybody fix/use that functionality?

>>> from apiclient.http import MediaFileUpload
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named http

Subdirectorys

Wouldn't it be better to put all files into subdirectorys based on the books name?

feature request: send to kindle

thanks for this awesome script!

what would be very cool is the send to kindle option, I use that a lot myself when I enter the daily deal. maybe I can look at implementing it myself, just wanted to know if you have thought about adding it.

is there away to download books that have not being sync

Is there away to download the books that already in my download list that have not being sync to my google drive? The reason because from time-to-time captcha fail and the books have to be downloa manually. So I left with a lots book unupdated to google drive.

problem with special characters?

during packtFreeBookDownloader.py execution:

Traceback (most recent call last):
File "packtFreeBookDownloader.py", line 187, in
downloader.downloadBooks(downloader.downloadBookTitles, downloader.downloadFormats)
File "packtFreeBookDownloader.py", line 156, in downloadBooks
if(os.path.isfile(fullFilePath)):
File "/usr/lib/python2.7/genericpath.py", line 37, in isfile
st = os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 31: ordinal not in range(128)

When using the switch -da

In addition when using the switch -da I've got
python3 packtPublishingFreeEbook.py -da
[INFO] - Creating session...
[INFO] - Session created, logged in successfully!
[INFO] - Getting data of all your books...
[INFO] - Opened 'https://www.packtpub.com/account/my-ebooks' successfully!
[ERROR] - Exception occurred 'NoneType' object has no attribute 'find_all'

Need an option to just download today's book

There's a -g to grab today's book, and -gd to grab and download it. Where is the -d to just download it? Or alternatively a -dt option (download this, a book specified on the command line, rather than having to edit/munge the config file)? Or even another alternative, make -gd smart enough not to try to grab the book again if it's already on your account, and just download it.

I don't use (or want to use) the anticaptcha, so I'm perfectly happy to login and get the book myself if it is something I want, I just want to use this to download today's book automatically in a cronjob after it's already in my account, which doesn't require captcha.

I've written a script that checks todays ebook, and sends me an email with the title, then if it's something I want I can grab it.

Currently if I try to use -gd, it complains that there's no section in the config file for ANTICAPTCHA_DATA. As a workaround, I've hacked the script not to look for the anticaptcha config, and to skip attempting the grab and instead only download.

Captcha?

How can we get this to work with the captcha?

Kr

Escape slashes ("/") from book titles

The slash ("/") is mistaken for a path separator on Unix, see example issue here:

downloading eBook: 'Oracle Advanced PL/SQL Developer Professional Guide' in '.pdf' format...
[ERROR] - Exception occured durin opening file [Errno 2] No such file or directory: '/home/daniel/myEbooksFromPackt/OracleAdvancedPl/sqlDeveloperProfessionalGuide.pdf'
--done--

Error downloading...

Unsure what happen. However today the books have not being able to downloaded and the script stop functioning (not being able to find the books)

Double check and the books do available and doing it manually it go into my download list.

screen shot 2018-03-04 at 4 22 18 pm

Feature request: grab a book and send email about success/failure

First of all - thanks, your script is saving me a few minutes every day.

Now I'm thinking about running this script on PythonAnywhere as a scheduled task and what I miss is a possibility to grab a book and send me an email whether script execution was successful. I've seen there are two similar features - to grab a book and log it into file and another one allowing to grab a book and email it to me.

I could try to fork your repo and implement such feature - would you consider accepting such pull request?

Have a good day,
Marcin

Logs issue - Fetching wrong info.

I've been using the script for a couple days and found out that the "grab ebook info" function, fetches the info (Description, Author and the date you got the book) of the first book in your library, it should be the info of the book that's currently available to get on free-ebooks.

I feel a better way of keeping a log would be: Title, description, Author, downloaded_at. What do you say? @igbt6

PoC:

TITLE --> Drupal 6 Search Engine Optimization
DESCRIPTION --> Learn to code like a professional with Python – an open source, versatile, and powerful programming language
AUTHOR --> Fabrizio Romano
TIME --> 2015-12-24
DOWNLOADED_AT --> 09-01-2017 22:24

TITLE --> WordPress 3 Complete
DESCRIPTION --> Learn to code like a professional with Python – an open source, versatile, and powerful programming language
AUTHOR --> Fabrizio Romano
TIME --> 2015-12-24
DOWNLOADED_AT --> 10-01-2017 20:23

I'd be up to work on this, I'm not too proficient in Python, but this seems like a nice entry issue to work on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.