Download all pdf files from Google scholar alert emails

I have gathered two many Google scholar alert emails. When i am with my laptops, i have much more fun things to do than reading papers. But when I am with my e-reader, there are only a small number of older documents. To keep documents in the e-reader updated, i added a cronjob to parse the scholar alert emails in Gmail's inbox, download all pdf files, push them into Google drive, so that next time, i could simply sync these folders again with my e-reader.

The alert email parsing file is a pure Python script, but the shell script which downloads gmails, and syncs files between local and Google drive depending on some personal binaries, which need to be replaced if you want to use, sorry. The csv_sql could be simply replaced by sqlite3, the pjobs could be replaced by parallel from moreutils, and sync between local and Google drive is optional.