From 60f1865b53f4f5205d2b7cb5578d9346964a9b5b Mon Sep 17 00:00:00 2001 From: taroxd Date: Mon, 15 Jul 2019 20:19:40 +0800 Subject: [PATCH 01/27] Fix typo --- contrib/Obok_calibre_plugin/obok_plugin_ReadMe.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/Obok_calibre_plugin/obok_plugin_ReadMe.txt b/contrib/Obok_calibre_plugin/obok_plugin_ReadMe.txt index 0170f7c..a7b8f1b 100644 --- a/contrib/Obok_calibre_plugin/obok_plugin_ReadMe.txt +++ b/contrib/Obok_calibre_plugin/obok_plugin_ReadMe.txt @@ -11,7 +11,7 @@ Open calibre's Preferences dialog. Click on the "Plugins" button. Next, click Customization ------------- -No customization is required, except choosing which menus will show the plugin. Altough the ability to enter a device serial number is given, this should not need to be filled in, as the serial number should be picked up automatically from the attached Kobo reader. +No customization is required, except choosing which menus will show the plugin. Although the ability to enter a device serial number is given, this should not need to be filled in, as the serial number should be picked up automatically from the attached Kobo reader. Using the plugin From 666af55404ec492c245e398c92f87f80f9de9717 Mon Sep 17 00:00:00 2001 From: taroxd Date: Mon, 15 Jul 2019 20:27:00 +0800 Subject: [PATCH 02/27] Update DeDRM_plugin_ReadMe.txt --- contrib/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt b/contrib/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt index 7dde68d..698f72a 100644 --- a/contrib/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt +++ b/contrib/DeDRM_calibre_plugin/DeDRM_plugin_ReadMe.txt @@ -50,7 +50,7 @@ When you have finished entering your configuration information, you must click t Troubleshooting --------------- -If you find that the DeDRM plugin is not working for you (imported ebooks still have DRM - that is, they won't convert or open in the calibre ebook viewer), you should make a log of the import process by deleting the DRMed ebook from calibre and then adding the ebook to calibre when it's running in debug mode. This will generate a lot of helpful debugging info that can be copied into any online help requests. Here's how to do it: +If you find that the DeDRM plugin is not working for you (imported ebooks still have DRM - that is, they won't convert or open in the calibre ebook viewer), you should make a log of the import process by deleting the DRMed ebook from calibre and then adding the ebook to calibre when it's running in debug mode. This will generate a lot of helpful debugging info that can be copied into any online help requests. Here's how to do it: - Remove the DRMed book from calibre. - Click the Preferences drop-down menu and choose 'Restart in debug mode'. From 57702b7d1763f32761850a78c0e2729aff356053 Mon Sep 17 00:00:00 2001 From: "Andrew (Paradi) Alexander" Date: Thu, 5 Sep 2019 12:04:40 -0400 Subject: [PATCH 03/27] Update link --- CALIBRE_CLI_INSTRUCTIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CALIBRE_CLI_INSTRUCTIONS.md b/CALIBRE_CLI_INSTRUCTIONS.md index d579348..dbda688 100644 --- a/CALIBRE_CLI_INSTRUCTIONS.md +++ b/CALIBRE_CLI_INSTRUCTIONS.md @@ -27,7 +27,7 @@ platforms. #### Enter your keys - Figure out what format DeDRM wants your key in by looking in - [the code that handles that](src/prefs.py). + [the code that handles that](dedrm_src/prefs.py). - For Kindle eInk devices, DeDRM expects you to put a list of serial numbers in the `serials` field: `"serials": ["012345689abcdef"]` or `"serials": ["1111111111111111", "2222222222222222"]`. From 0e9e3cf7ca252bedbc4966ebf6c9bcfa3f17068d Mon Sep 17 00:00:00 2001 From: Cory Solovewicz Date: Sat, 5 Oct 2019 12:03:59 -0700 Subject: [PATCH 04/27] Update FAQs.md Update formatting: Wrap all filenames, file paths, and terminal commands in code quotes and cleaned up the file hashes by putting them in an unordered ist. --- FAQs.md | 76 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/FAQs.md b/FAQs.md index dd43f19..0791d3a 100644 --- a/FAQs.md +++ b/FAQs.md @@ -22,30 +22,32 @@ But otherwise, if your ebook is from Amazon, Kobo, Barnes & Noble or any of the ### A Recent Change to Kindle for PC/Kindle for Mac Starting with version 1.19, Kindle for PC/Mac uses Amazon's new KFX format which isn't quite as good a source fro conversion to ePub as the older KF8 (& MOBI) formats. There are two options to get the older formats. Either stick with version 1.17 or earlier, or modify the executable by changing a file name. Note that with Kindle for PC/Mac 1.25 and later, there is no current solution even for FKX. You must use 1.24 or earlier. -Version 1.17 of Kindle is are no longer available directly from Amazon, so you will need to search for the proper file name and find it on a third party site. The name is "KindleForPC-installer-1.17.44170.exe" for PC and "KindleForMac-44182.dmg" for Mac. +Version 1.17 of Kindle is are no longer available directly from Amazon, so you will need to search for the proper file name and find it on a third party site. The name is `KindleForPC-installer-1.17.44170.exe` for PC and `KindleForMac-44182.dmg` for Mac. Verify the one of the following cryptographic hash values, using software of your choice, before installing the downloaded file in order to avoid viruses. If the hash does not match, delete the downloaded file and try again from another site. -Kindle for PC: -MD-5: 53F793B562F4823721AA47D7DE099869 -SHA-1: 73C404D719F0DD8D4AE1C2C96612B095D6C86255 -SHA-256: 14E0F0053F1276C0C7C446892DC170344F707FBFE99B695176 2C120144163200 -Kindle for Mac: -MD-5: E7E36D5369E1F3CF1D28E5D9115DF15F -SHA-1: 7AB9A86B954CB23D622BD79E3257F8E2182D791C -SHA-256: 28DC21246A9C7CDEDD2D6F0F4082E6BF7EF9DB9CE9D485548E 8A9E1D19EAE2AC. + +#### Kindle for PC `KindleForPC-installer-1.17.44170.exe`: +* MD-5: 53F793B562F4823721AA47D7DE099869 +* SHA-1: 73C404D719F0DD8D4AE1C2C96612B095D6C86255 +* SHA-256: 14E0F0053F1276C0C7C446892DC170344F707FBFE99B695176 2C120144163200 + +#### Kindle for Mac `KindleForMac-44182.dmg`: +* MD-5: E7E36D5369E1F3CF1D28E5D9115DF15F +* SHA-1: 7AB9A86B954CB23D622BD79E3257F8E2182D791C +* SHA-256: 28DC21246A9C7CDEDD2D6F0F4082E6BF7EF9DB9CE9D485548E 8A9E1D19EAE2AC. You will need to go to the preferences and uncheck the auto update checkbox. Then download and install 1.17 over the top of the 1.19 installation. You'll also need to delete the KFX folders from your My Kindle Content folder. A other possible solution is to use 1.19 or later, but disable KFX by renaming or disabling a necessary component of the application. This may or may not work on versions after 1.20. In a command window, enter the following commands when Kindle for PC/Mac is not running: #### Windows -ren %localappdata%\Amazon\Kindle\application\renderer-test.exe renderer-test.xxx +`ren %localappdata%\Amazon\Kindle\application\renderer-test.exe renderer-test.xxx` -PC Note: The renderer-test program may be in a different location in some Kindle for PC installations. If the rename command fails look in other folders, such as C:\Program Files\Amazon\Kindle. +PC Note: The renderer-test program may be in a different location in some Kindle for PC installations. If the rename command fails look in other folders, such as `C:\Program Files\Amazon\Kindle`. #### Macintosh -chmod -x /Applications/Kindle.app/Contents/MacOS/renderer-test +`chmod -x /Applications/Kindle.app/Contents/MacOS/renderer-test` -Mac Note: If the chmod command fails with a permission error try again using sudo before chmod - sudo chmod [...] +Mac Note: If the chmod command fails with a permission error try again using `sudo` before `chmod` - `sudo chmod` [...] After restarting the Kindle program any books previously downloaded in KFX format will no longer open. You will need to remove them from your device and re-download them. All future downloads will use the older Kindle formats instead of KFX although they will continue to be placed in one individual subdirectory per book. @@ -56,10 +58,10 @@ Thanks to work by several people, the tools can now decrypt KFX format ebooks fr Thanks to jhowell for his investigations into KFX format and the KFX Input plugin. Some of these instructions are from [his thread on the subject](https://www.mobileread.com/forums/showthread.php?t=283371) at MobileRead. ## Where can I get the latest version of these free DRM removal tools? -Right here at github. Just go to the [releases page](https://github.com/apprenticeharper/DeDRM_tools/releases) and download the latest zip archive of the tools, named DeDRM\_tools\_X.X.X.zip, where X.X.X is the version number. You do not need to download the source code archive. +Right here at github. Just go to the [releases page](https://github.com/apprenticeharper/DeDRM_tools/releases) and download the latest zip archive of the tools, named `DeDRM\_tools\_X.X.X.zip`, where X.X.X is the version number. You do not need to download the source code archive. ## I've downloaded the tools archive. Now what? -First, unzip the archive. You should now have a DeDRM folder containing several other folders and a ReadMe\_First.txt file. Please read the ReadMe\_First file! That will explain what the folders are, and you'll be able to work out which of the tools you need. +First, unzip the archive. You should now have a DeDRM folder containing several other folders and a `ReadMe_First.txt` file. Please read the `ReadMe_First.txt` file! That will explain what the folders are, and you'll be able to work out which of the tools you need. ## That's a big complicated ReadMe file! Isn't there a quick guide? Install calibre. Install the DeDRM\_plugin in calibre. Install the Obok\_plugin in calibre. Restart calibre. In the DeDRM_plugin customisation dialog add in any E-Ink Kindle serial numbers and your B&N account email address and password. Remember that the plugin only tries to remove DRM when ebooks are imported. @@ -67,14 +69,14 @@ Install calibre. Install the DeDRM\_plugin in calibre. Install the Obok\_plugin # Installing the Tools ## The calibre plugin ### I am trying to install the calibre plugin, but calibre says "ERROR: Unhandled exception: InvalidPlugin: The plugin in u’[path]DeDRM\_tools\_6.5.3.zip’ is invalid. It does not contain a top-level \_\_init\_\_.py file" -You are trying to add the tools archive (e.g. DeDRM\_tools\_6.5.3.zip) instead of the plugin. The tools archive is not the plugin. It is a collection of DRM removal tools which includes the plugin. You must unzip the archive, and install the calibre plugin (DeDRM\_plugin.zip) from a folder called “DeDRM\_calibre_plugin” in the unzipped archive. +You are trying to add the tools archive (e.g. `DeDRM_tools_6.5.3.zip`) instead of the plugin. The tools archive is not the plugin. It is a collection of DRM removal tools which includes the plugin. You must unzip the archive, and install the calibre plugin `DeDRM_plugin.zip` from a folder called `DeDRM_calibre_plugin` in the unzipped archive. ### I’ve unzipped the tools archive, but I can’t find the calibre plugin when I try to add them to calibre. I use Windows. -You should select the zip file that is in the “DeDRM\_calibre\_plugin” folder, not any files inside the plugin’s zip archive. Make sure you are selecting from the folder that you created when you unzipped the tools archive and not selecting a file inside the still-zipped tools archive. +You should select the zip file that is in the `DeDRM_calibre_plugin` folder, not any files inside the plugin’s zip archive. Make sure you are selecting from the folder that you created when you unzipped the tools archive and not selecting a file inside the still-zipped tools archive. -(The problem is that Windows will allow apps to browse inside zip archives without needing to unzip them first. If there are zip archives inside the main zip archives, Windows will show them as unzipped as well. So what happens is people will unzip the DeDRM\_tools\_X.X.X.zip to a folder, but when using calibre they will actually navigate to the still zipped file by mistake and cannot tell they have done so because they do not have file extensions showing. So to the unwary Windows user, it appears that the zip archive was unzipped and that everything inside it was unzipped as well so there is no way to install the plugins. +(The problem is that Windows will allow apps to browse inside zip archives without needing to unzip them first. If there are zip archives inside the main zip archives, Windows will show them as unzipped as well. So what happens is people will unzip the `DeDRM_tools_X.X.X.zip` to a folder, but when using calibre they will actually navigate to the still zipped file by mistake and cannot tell they have done so because they do not have file extensions showing. So to the unwary Windows user, it appears that the zip archive was unzipped and that everything inside it was unzipped as well so there is no way to install the plugins. -We strongly recommend renaming the DeDRM\_tools\_X.X.X.zip archive (after extracting its contents) to DeDRM\_tools\_X.X.X_archive.zip. If you do that, you are less likely to navigate to the wrong location from inside calibre.) +We strongly recommend renaming the `DeDRM_tools_X.X.X.zip` archive (after extracting its contents) to `DeDRM_tools_X.X.X_archive.zip`. If you do that, you are less likely to navigate to the wrong location from inside calibre.) ## The Windows Application ### I've installed ActiveState Python and PyCrypto, but the Windows application won't run. What have I done wrong? @@ -87,7 +89,7 @@ Try right-clicking and select open. That might give you the option to open it an ### I can't open the Macintosh Application at all. I get 'The aplication "DeDRM" can't be opened' Some unzip applications do not respect the execution bit setting. Try unzipping the main tools archive using the built-in Mac unzip utility. -Alternatively, sometimes the execution bit isn't set correctly in the archive. If you put the extracted DeDRM application in your Applications folder, you can set the executable bit on the 'droplet' file from the terminal using the command chmod +x /Applications/DeDRM.app/Contents/MacOS/droplet +Alternatively, sometimes the execution bit isn't set correctly in the archive. If you put the extracted DeDRM application in your Applications folder, you can set the executable bit on the 'droplet' file from the terminal using the command `chmod +x /Applications/DeDRM.app/Contents/MacOS/droplet` ### I can't open the Macintosh Application at all. I get 'spawn_via_launchd() failed, errno=111' There seems to be a bug in Apple's launch services. Try using the free [Maintenance utility](https://www.titanium-software.fr/en/maintenance.html) from Titanium Software to clear the launch cache and database. @@ -95,28 +97,28 @@ There seems to be a bug in Apple's launch services. Try using the free [Maintena ### The application opens, but always gives an error in the log 'ImportError: No module named Crypto.Cipher' Some version of MacOS don't include PyCrpto. You'll need to install it manually. In Terminal window: -sudo python -m pip install pycrypto +`sudo python -m pip install pycrypto` if error “No module named pip”, type: -sudo easy_install pip +`sudo easy_install pip` -try again: sudo python -m pip install pycrypto +try again: `sudo python -m pip install pycrypto` if installation fails because “C compiler cannot create executables” and pop-up window asks you to install Command Line Tools for XCode, agree by clicking “Continue” -try again: sudo python -m pip install pycrypto +try again: `sudo python -m pip install pycrypto` If after installing pycrypto decryption still fails with something about pylzma in error log, try: -sudo python -m pip install pylzma +`sudo python -m pip install pylzma` # Using the Tools ## I can’t get the tools to work on my rented or library ebooks. The tools are not designed to remove DRM from rented or library ebooks. ## I've unzipped the tools, but what are all the different files, and how do I use them? -Read the ReadMe_First.txt file and then the ReadMe files included in the tools folder(s) you're interested in. That's what they're for. +Read the `ReadMe_First.txt` file and then the ReadMe files included in the tools folder(s) you're interested in. That's what they're for. ## I have installed the calibre plugin, but my books still have DRM. When I try to view or convert my books, calibre says they have DRM. DRM only gets removed when an ebook is imported into calibre. Also, if the book is already in calibre, by default calibre will discard the newly imported file. You can change this in calibre's Adding books preferences page (Automerge..../Overwrite....), so that newly imported files overwrite existing ebook formats. Then just re-import your books and the DRM-free versions will overwrite the DRMed versions while retaining your books' metadata. @@ -127,16 +129,16 @@ Your ebooks are stored on your computer or on your ebook reader. You need to fin ### Macintosh Navigating from your home folder, -Kindle for Mac ebooks are in either Library/Application Support/Kindle/My Kindle Content or Documents/My Kindle Content or Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/My Kindle Content, depending on your version of Kindle for Mac. +Kindle for Mac ebooks are in either `Library/Application Support/Kindle/My Kindle Content` or `Documents/My Kindle Content or Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/My Kindle Content`, depending on your version of Kindle for Mac. -Adobe Digital Editions ebooks are in Documents/Digital Editions +Adobe Digital Editions ebooks are in `Documents/Digital Editions` ### Windows -Navigating from your "Documents" folder ("My Documents" folder, pre-Windows 7) +Navigating from your `Documents` folder (`My Documents` folder, pre-Windows 7) -Kindle for PC ebooks are in My Kindle Content +Kindle for PC ebooks are in `My Kindle Content` -Adobe Digital Editions ebooks are in My Digital Editions +Adobe Digital Editions ebooks are in `My Digital Editions` ## I have installed the calibre plugin, and the book is not already in calibre, but the DRM does not get removed. @@ -150,15 +152,15 @@ If this book is from an eInk Kindle (e.g. Paperwhite), you must enter the serial If this book is from Kindle for Mac or Kindle for PC, you must have the Kindle Software installed on the same computer and user account as your copy of calibre. -If this book is from Kindle for Mac you must be using version 1.24 or below, even if you have the Input plugin installed. +If this book is from Kindle for Mac you must be using version 1.24 or below, even if you have the Input plugin installed. If the book is from Kindle for PC or Kindle for Mac and you think you are doing everything right, and you are getting this message, it is possible that the files containing the encryption key aren’t quite in the format the tools expect. To try to fix this: 1. Deregister Kindle for PC(Mac) from your Amazon account. 1. Uninstall Kindle for PC(Mac) 1. Delete the Kindle for PC(Mac) preferences - * PC: Delete the directory [home folder]\AppData\Local\Amazon (it might be hidden) and [home folder]\My Documents\My Kindle Content - * Mac: Delete the directory [home folder]/Library/Application Support/Kindle/and/or [home folder]/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/ (one or both may be present and should be deleted) + * PC: Delete the directory `[home folder]\AppData\Local\Amazon` (it might be hidden) and `[home folder]\My Documents\My Kindle Content` + * Mac: Delete the directory `[home folder]/Library/Application Support/Kindle/` and/or `[home folder]/Library/Containers/com.amazon.Kindle/Data/Library/Application Support/Kindle/` (one or both may be present and should be deleted) 1. Reinstall Kindle for PC(Mac) version 1.17 or earlier (see above for download links). 1. Re-register Kindle for PC(Mac) with your Amazon account 1. Download the ebook again. Do not use the files you have downloaded previously. @@ -171,7 +173,7 @@ There are several possible reasons why only some books get their DRM removed. If you are still having problems with particular books, you will need to create a log of the DRM removal attempt for one of the problem books, and post that in a comment at Apprentice Alf's blog or in a new issue at Apprentice Harper's github repository. ## My Kindle book has imported and the DRM has been removed, but all the pictures are gone. -Most likely, this is a book downloaded from Amazon directly to an eInk Kindle (e.g. Paperwhite). Unfortunately, the pictures are probably in a .azw6 file that the tools don't understand. You must download the book manually from Amazon's web site "For transfer via USB" to your Kindle. When you download the eBook in this manner, Amazon will package the pictures in the with text in a single file that the tools will be able to import successfully. +Most likely, this is a book downloaded from Amazon directly to an eInk Kindle (e.g. Paperwhite). Unfortunately, the pictures are probably in a `.azw6` file that the tools don't understand. You must download the book manually from Amazon's web site "For transfer via USB" to your Kindle. When you download the eBook in this manner, Amazon will package the pictures in the with text in a single file that the tools will be able to import successfully. ## My Kindle book has imported, but it's showing up as an AZW4 format. Conversions take a long time and/or are very poor. You have found a Print Replica Kindle ebook. This is a PDF in a Kindle wrapper. Now the DRM has been removed, you can extract the PDF from the wrapper using the KindleUnpack plugin. Conversion of PDFs rarely gives good results. @@ -195,7 +197,7 @@ Remove the DRMed book from calibre. Click the Preferences drop-down menu and cho The Macintosh DeDRM application creates a log file on your desktop every time it is run. After unsuccessfully removing DRM from one ebook, copy the contents of the log file (it is a simple text file) and paste it into your comment at Apprentice Alf's blog or in a new issue at Apprentice Harper's github repository. ## I cannot solve my problem with the Windows DeDRM application, and now I need to ‘post a log’. How do I do that? -The Windows DeDRM application creates a log file in your home directory (C:\Users\[username]) every time it is run. After unsuccessfully removing DRM from one ebook, copy the contents of the log file (it is a simple text file) and paste it into your comment at Apprentice Alf's blog or in a new issue at Apprentice Harper's github repository. +The Windows DeDRM application creates a log file in your home directory `C:\Users\[username]` every time it is run. After unsuccessfully removing DRM from one ebook, copy the contents of the log file (it is a simple text file) and paste it into your comment at Apprentice Alf's blog or in a new issue at Apprentice Harper's github repository. ## Is there a way to use the DeDRM plugin for Calibre from the command line? See the [Calibre command line interface (CLI) instructions](CALIBRE_CLI_INSTRUCTIONS.md). @@ -231,7 +233,7 @@ Amazon turned off backup for Kindle for Android, so the tools can no longer find Apple regularly change the details of their DRM and so the tools in the main tools archive will not work with these ebooks. Apple’s Fairplay DRM scheme can be removed using Requiem if the appropriate version of iTunes can still be installed and used. See the post Apple and ebooks: iBookstore DRM and how to remove it at Apprentice Alf's blog for more details. ## I’ve got the tools archive and I’ve read all the FAQs but I still can’t install the tools and/or the DRM removal doesn’t work -* Read the ReadMe_First.txt file in the top level of the tools archive +* Read the `ReadMe_First.txt` file in the top level of the tools archive * Read the ReadMe file in the folder of the tools you want to use. * If you still can’t remove the DRM, ask in the comments section of Apprentice Alf's blog or create a new issue at Apprentice Harper's github repository, reporting the error as precisely as you can, what platform you use, what tool you have tried, what errors you get, and what versions you are using. If the problem happens when running one of the tools, post a log (see previous questions on how to do this). From 952b7fa7c06b99210a4c1eefb00025adb31cd2d5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 17 Dec 2019 08:51:25 +0100 Subject: [PATCH 05/27] GitHub Actions: Lint and test our Python code --- .github/workflows/Python_tests.yml | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/Python_tests.yml diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml new file mode 100644 index 0000000..a9ad8f8 --- /dev/null +++ b/.github/workflows/Python_tests.yml @@ -0,0 +1,35 @@ +name: Python_tests +on: [push, pull_request] +jobs: + Python_tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest] + python-version: [2.7, 3.8] + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest -r requirements.txt + #- name: Check formatting with black + # if: matrix.python-version == '3.8' + # run: | + # pip install black + # black --check . + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + #- name: Test with pytest + # run: pytest + #- name: Run doctests with pytest + # run: pytest --doctest-modules From ff51ee82275ae21c0c4bcabbaa594c0b8f1514cb Mon Sep 17 00:00:00 2001 From: Jake Marsden Date: Sun, 29 Dec 2019 23:30:29 +1300 Subject: [PATCH 06/27] Fix very minor typo in contrib README --- contrib/ReadMe_First.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/ReadMe_First.txt b/contrib/ReadMe_First.txt index 9511ce4..d9300bf 100644 --- a/contrib/ReadMe_First.txt +++ b/contrib/ReadMe_First.txt @@ -90,7 +90,7 @@ Windows and Python ------------------ We **strongly** recommend using calibre and the plugin. -If you really want to use the WIndows app or the individual scripts, you'll need to install python. +If you really want to use the Windows app or the individual scripts, you'll need to install python. ActiveState's Active Python 2.7 Community Edition for Windowscan be downloaded for free from: http://www.activestate.com/activepython/downloads From fc6f830088992ca7300b5c275db4206905061323 Mon Sep 17 00:00:00 2001 From: Carson Gaspar Date: Sat, 4 Jan 2020 05:20:16 -0800 Subject: [PATCH 07/27] Update lzma import to include calibre >= 4.6.0 --- dedrm_src/ion.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dedrm_src/ion.py b/dedrm_src/ion.py index 40433ca..c361d20 100644 --- a/dedrm_src/ion.py +++ b/dedrm_src/ion.py @@ -21,19 +21,24 @@ from Crypto.Cipher import AES from Crypto.Util.py3compat import bchr, bord try: - # lzma library from calibre 2.35.0 or later - import lzma.lzma1 as calibre_lzma + # lzma library from calibre 4.6.0 or later + import calibre_lzma.lzma1 as calibre_lzma except ImportError: calibre_lzma = None + # lzma library from calibre 2.35.0 or later try: - import lzma + import lzma.lzma1 as calibre_lzma except ImportError: - # Need pip backports.lzma on Python <3.3 + calibre_lzma = None try: - from backports import lzma + import lzma except ImportError: - # Windows-friendly choice: pylzma wheels - import pylzma as lzma + # Need pip backports.lzma on Python <3.3 + try: + from backports import lzma + except ImportError: + # Windows-friendly choice: pylzma wheels + import pylzma as lzma TID_NULL = 0 From 798a7f9c8e5f0ca0fb6a433b9d0f2dead242949f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:35:10 +0100 Subject: [PATCH 08/27] GitHub Action: There is no requirements.txt --- .github/workflows/Python_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index a9ad8f8..1a6e422 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest -r requirements.txt + pip install flake8 pytest # -r requirements.txt #- name: Check formatting with black # if: matrix.python-version == '3.8' # run: | From 48dac1421869d51e215cb7d492c4cbb158d788b6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:39:27 +0100 Subject: [PATCH 09/27] builtins=_ --- .github/workflows/Python_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index 1a6e422..e07c1b2 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -9,7 +9,7 @@ jobs: os: [macos-latest] python-version: [2.7, 3.8] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v1 with: @@ -26,9 +26,9 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics #- name: Test with pytest # run: pytest #- name: Run doctests with pytest From ae703e523cfe5134f4f512e3b0a24d30c2481148 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:41:14 +0100 Subject: [PATCH 10/27] flake8 . --builtins=_ --- .github/workflows/Python_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index e07c1b2..6d6b10d 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -26,9 +26,9 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics #- name: Test with pytest # run: pytest #- name: Run doctests with pytest From c74f4b20d38411db04514348fd0752b43013e92c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:45:36 +0100 Subject: [PATCH 11/27] Undefined name: from datetime import datetime --- obok_src/common_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/obok_src/common_utils.py b/obok_src/common_utils.py index 964753f..0f2164a 100644 --- a/obok_src/common_utils.py +++ b/obok_src/common_utils.py @@ -8,6 +8,7 @@ __copyright__ = '2012, David Forrester ' __docformat__ = 'restructuredtext en' import os, time, re, sys +from datetime import datetime try: from PyQt5.Qt import (Qt, QIcon, QPixmap, QLabel, QDialog, QHBoxLayout, QProgressBar, QTableWidgetItem, QFont, QLineEdit, QComboBox, From 89cf29cb7835a35c85c7f8c6c595b2b832fb7492 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:46:20 +0100 Subject: [PATCH 12/27] flake8 . --builtins=_,I --- .github/workflows/Python_tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index 6d6b10d..65215df 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -26,9 +26,9 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --builtins=_ --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --builtins=_,I --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --builtins=_ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --builtins=_,I --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics #- name: Test with pytest # run: pytest #- name: Run doctests with pytest From e4c1a09d45dd47841b16324a2274752c974fd9d5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:49:02 +0100 Subject: [PATCH 13/27] Undefined name: import traceback --- dedrm_src/epubtest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/epubtest.py b/dedrm_src/epubtest.py index 11f1427..eb9af5a 100644 --- a/dedrm_src/epubtest.py +++ b/dedrm_src/epubtest.py @@ -48,7 +48,7 @@ from __future__ import with_statement __version__ = '1.01' -import sys, struct, os +import sys, struct, os, traceback import zlib import zipfile import xml.etree.ElementTree as etree From 616548a9a8b04810db7da6e463aabebd3e31aea5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:52:54 +0100 Subject: [PATCH 14/27] Undefined name: import traceback for line 70 --- dedrm_src/wineutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/wineutils.py b/dedrm_src/wineutils.py index 0485e5e..df1755f 100644 --- a/dedrm_src/wineutils.py +++ b/dedrm_src/wineutils.py @@ -6,7 +6,7 @@ from __future__ import with_statement __license__ = 'GPL v3' # Standard Python modules. -import os, sys, re, hashlib +import os, sys, re, hashlib, traceback from calibre_plugins.dedrm.__init__ import PLUGIN_NAME, PLUGIN_VERSION def WineGetKeys(scriptpath, extension, wineprefix=""): From 1fd972ee1735ce48b29c257571e6a7786e73e4b6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 13:54:20 +0100 Subject: [PATCH 15/27] Identity is not the same thing as equality in Python --- dedrm_src/mobidedrm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/mobidedrm.py b/dedrm_src/mobidedrm.py index 501aa2d..cc7baf2 100644 --- a/dedrm_src/mobidedrm.py +++ b/dedrm_src/mobidedrm.py @@ -524,7 +524,7 @@ def cli_main(): else: infile = argv[1] outfile = argv[2] - if len(argv) is 4: + if len(argv) == 4: pidlist = argv[3].split(',') else: pidlist = [] From e35b37c4f444b9429ddfb0b25839d50dd70c151e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:29:03 +0100 Subject: [PATCH 16/27] Undefined name: from .convert2xml import encodeNumber --- dedrm_src/genbook.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dedrm_src/genbook.py b/dedrm_src/genbook.py index 4036896..3ec6ccf 100644 --- a/dedrm_src/genbook.py +++ b/dedrm_src/genbook.py @@ -1,6 +1,8 @@ #! /usr/bin/python # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab +from .convert2xml import encodeNumber + class Unbuffered: def __init__(self, stream): self.stream = stream From 7edebeef0da779af9c3e8b4daa3a1a0efccde2ac Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:33:16 +0100 Subject: [PATCH 17/27] import erdr2pml, ineptpdf, k4mobidedrm --- dedrm_src/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dedrm_src/__init__.py b/dedrm_src/__init__.py index cdd4e7b..ec4c621 100644 --- a/dedrm_src/__init__.py +++ b/dedrm_src/__init__.py @@ -87,6 +87,10 @@ import zipfile import traceback from zipfile import ZipFile +import erdr2pml +import ineptpdf +import k4mobidedrm + class DeDRMError(Exception): pass From a10d9a617ffc31925a8f83ca6836af78cbd792b4 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:34:56 +0100 Subject: [PATCH 18/27] Undefined name: Error() --> ValueError() --- dedrm_src/pycrypto_des.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/pycrypto_des.py b/dedrm_src/pycrypto_des.py index 80d7d65..286df9f 100644 --- a/dedrm_src/pycrypto_des.py +++ b/dedrm_src/pycrypto_des.py @@ -11,7 +11,7 @@ def load_pycrypto(): class DES(object): def __init__(self, key): if len(key) != 8 : - raise Error('DES improper key used') + raise ValueError('DES improper key used') self.key = key self._des = _DES.new(key,_DES.MODE_ECB) def desdecrypt(self, data): From 90335bb925a82f1de3ef065120d5b22e7cdb416e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:41:29 +0100 Subject: [PATCH 19/27] Undefined name: Define RegError --- dedrm_src/kindlekey.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dedrm_src/kindlekey.py b/dedrm_src/kindlekey.py index ec0adde..7e02b6c 100644 --- a/dedrm_src/kindlekey.py +++ b/dedrm_src/kindlekey.py @@ -40,6 +40,12 @@ from struct import pack, unpack, unpack_from import json import getopt +try: + RegError +except NameError: + class RegError(Exception): + pass + # Routines common to Mac and PC # Wrap a stream so that output gets flushed immediately From 8c08c67aa801bf9ea06dfc0300555d173ecb37e8 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:47:04 +0100 Subject: [PATCH 20/27] Undefined name: import zipfix --- dedrm_src/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dedrm_src/__init__.py b/dedrm_src/__init__.py index ec4c621..ec98886 100644 --- a/dedrm_src/__init__.py +++ b/dedrm_src/__init__.py @@ -90,6 +90,7 @@ from zipfile import ZipFile import erdr2pml import ineptpdf import k4mobidedrm +import zipfix class DeDRMError(Exception): pass From 4e26b9d4e7b42c9f00d033a140199139d8b15208 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:55:42 +0100 Subject: [PATCH 21/27] Undefined name: errlog = '' --- dedrm_src/scriptinterface.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dedrm_src/scriptinterface.py b/dedrm_src/scriptinterface.py index ec86b13..6154a2a 100644 --- a/dedrm_src/scriptinterface.py +++ b/dedrm_src/scriptinterface.py @@ -114,6 +114,7 @@ def decryptpdf(infile, outdir, rscpath): def decryptpdb(infile, outdir, rscpath): + errlog = '' outname = os.path.splitext(os.path.basename(infile))[0] + ".pmlz" outpath = os.path.join(outdir, outname) rv = 1 From 0955713cd6061ca30f65434f231e1461a8e3c447 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 14:58:03 +0100 Subject: [PATCH 22/27] Undefined name: errlog = '' --- dedrm_src/scriptinterface.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dedrm_src/scriptinterface.py b/dedrm_src/scriptinterface.py index 6154a2a..8cadade 100644 --- a/dedrm_src/scriptinterface.py +++ b/dedrm_src/scriptinterface.py @@ -142,6 +142,7 @@ def decryptpdb(infile, outdir, rscpath): def decryptk4mobi(infile, outdir, rscpath): + errlog = '' rv = 1 pidnums = [] pidspath = os.path.join(rscpath,'pidlist.txt') From eddbefcf915009620896d5bf68e87ae6959272c0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 15:11:14 +0100 Subject: [PATCH 23/27] Undefined name: strip(uuidnum) --> uuidnum.strip() --- dedrm_src/kindlekey.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/kindlekey.py b/dedrm_src/kindlekey.py index 7e02b6c..7b994ed 100644 --- a/dedrm_src/kindlekey.py +++ b/dedrm_src/kindlekey.py @@ -1308,7 +1308,7 @@ elif isosx: uuids = [] uuidnum = os.getenv('MYUUIDNUMBER') if uuidnum != None: - uuids.append(strip(uuidnum)) + uuids.append(uuidnum.strip()) cmdline = '/usr/sbin/ioreg -l -S -w 0 -r -c AppleAHCIDiskDriver' cmdline = cmdline.encode(sys.getfilesystemencoding()) p = subprocess.Popen(cmdline, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False) From 0895aeb32370348c1e871af5b378df6a9f0a7f83 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 15:17:06 +0100 Subject: [PATCH 24/27] Undefined name: from ignoblekeygen import generate_key --- dedrm_src/utilities.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dedrm_src/utilities.py b/dedrm_src/utilities.py index c730607..c62b043 100644 --- a/dedrm_src/utilities.py +++ b/dedrm_src/utilities.py @@ -3,6 +3,8 @@ from __future__ import with_statement +from ignoblekeygen import generate_key + __license__ = 'GPL v3' DETAILED_MESSAGE = \ From b35f7775802ffd34a5e34546f18dd6f6cf40ea1f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 20 Jan 2020 15:23:19 +0100 Subject: [PATCH 25/27] Focus only on legacy Python for now --- .github/workflows/Python_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Python_tests.yml b/.github/workflows/Python_tests.yml index 65215df..57b08ce 100644 --- a/.github/workflows/Python_tests.yml +++ b/.github/workflows/Python_tests.yml @@ -7,7 +7,7 @@ jobs: fail-fast: false matrix: os: [macos-latest] - python-version: [2.7, 3.8] + python-version: [2.7] # , 3.8] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} From 795f413ecbe09a3b20edceb9a4627e403a0e2003 Mon Sep 17 00:00:00 2001 From: Apprentice Harper Date: Thu, 23 Jan 2020 12:14:19 +0000 Subject: [PATCH 26/27] Allow Kindle serial numbers to have spaces, allowing copy/paste from Amazon web site (thanks to jakemarsden) --- dedrm_src/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dedrm_src/config.py b/dedrm_src/config.py index 3a56e44..98ce6e0 100644 --- a/dedrm_src/config.py +++ b/dedrm_src/config.py @@ -879,7 +879,7 @@ class AddSerialDialog(QDialog): @property def key_value(self): - return unicode(self.key_ledit.text()).strip() + return unicode(self.key_ledit.text()).replace(' ', '') def accept(self): if len(self.key_name) == 0 or self.key_name.isspace(): From ce8538a2ca81c5e741647d724de9c5fca36db91b Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 23 Jan 2020 13:24:45 +0100 Subject: [PATCH 27/27] Remove the unused rename_key() method --- obok_src/config.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/obok_src/config.py b/obok_src/config.py index ae4edc0..645c9e3 100644 --- a/obok_src/config.py +++ b/obok_src/config.py @@ -145,28 +145,6 @@ class ManageKeysDialog(QDialog): self.listy.clear() self.populate_list() - def rename_key(self): - if not self.listy.currentItem(): - errmsg = u"No {0} selected to rename. Highlight a keyfile first.".format(self.key_type_name) - r = error_dialog(None, "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION), - _(errmsg), show=True, show_copy_button=False) - return - - d = RenameKeyDialog(self) - d.exec_() - - if d.result() != d.Accepted: - # rename cancelled or moot. - return - keyname = unicode(self.listy.currentItem().text()) - if not question_dialog(self, "{0} {1}: Confirm Rename".format(PLUGIN_NAME, PLUGIN_VERSION), u"Do you really want to rename the {2} named {0} to {1}?".format(keyname,d.key_name,self.key_type_name), show_copy_button=False, default_yes=False): - return - self.plugin_keys[d.key_name] = self.plugin_keys[keyname] - del self.plugin_keys[keyname] - - self.listy.clear() - self.populate_list() - def delete_key(self): if not self.listy.currentItem(): return