Skip to content

Instantly share code, notes, and snippets.

@marccarre
Created October 24, 2020 08:46
Show Gist options
  • Save marccarre/645fe68da31678f9191cd3aafecfea1b to your computer and use it in GitHub Desktop.
Save marccarre/645fe68da31678f9191cd3aafecfea1b to your computer and use it in GitHub Desktop.
List all available versions of Kindle for Mac and Kindle for PC.
#!/usr/bin/env python
'''
List all available versions of Kindle for Mac and Kindle for PC.
Dependencies:
- asyncio==3.4.3
- aiohttp==3.6.3
'''
import os
import sys
import asyncio
import aiohttp
MAX_ATTEMPTS = int(os.environ.get('MAX_ATTEMPTS', 3)) # Maximum number of attempts per URL.
RATE_LIMIT = int(os.environ.get('RATE_LIMIT', 64)) # Number of active requests at any given time.
'''
Build numbers (5XXXX) increment:
- by 1000 for minor versions
- by 1 for patch versions -- with gaps, as some builds are not released.
'''
VERSIONS = [
{'build': 55000, 'version': '1.26'},
{'build': 56000, 'version': '1.27'},
{'build': 57000, 'version': '1.28'},
{'build': 58000, 'version': '1.29'},
{'build': 59000, 'version': '1.30'},
]
'''
For example:
- Kindle 1.26
- https://s3.amazonaws.com/kindleforpc/55076/KindleForPC-installer-1.26.55076.exe
- https://s3.amazonaws.com/kindleformac/55093/KindleForMac-55093.dmg
- Kindle 1.30
- https://s3.amazonaws.com/kindleforpc/59056/KindleForPC-installer-1.30.59056.exe
- https://s3.amazonaws.com/kindleformac/59055/KindleForMac-1.30.59055.dmg
'''
URL_PATTERNS = [
'https://s3.amazonaws.com/kindleforpc/{build}/KindleForPC-installer-{version}.{build}.exe',
'https://s3.amazonaws.com/kindleformac/{build}/KindleForMac-{build}.dmg',
'https://s3.amazonaws.com/kindleformac/{build}/KindleForMac-{version}.{build}.dmg',
]
async def main():
async with aiohttp.ClientSession() as session:
urls = await fetch_all(session)
print('\n'.join(sorted([url for url in urls if url])))
async def fetch_all(session):
tasks = []
semaphore = asyncio.Semaphore(RATE_LIMIT)
for v in VERSIONS:
for build in range(v['build'], v['build'] + 1000):
for pattern in URL_PATTERNS:
url = pattern.format(build=build, version=v['version'])
task = asyncio.create_task(fetch(session, semaphore, url))
tasks.append(task)
results = await asyncio.gather(*tasks)
return results
async def fetch(session, semaphore, url):
for attempt in range(1, MAX_ATTEMPTS + 1):
try:
async with semaphore:
response = await session.head(url)
return url if response.status == 200 else None
except Exception as e:
if attempt < MAX_ATTEMPTS:
print('Attempt #%d: Retrying on %s as got: %s.' % (attempt, url, e), file=sys.stderr)
else:
print('Failed on %s with: %s' % (url, e), file=sys.stderr)
if __name__ == '__main__':
asyncio.run(main())
@Young-Lord
Copy link

AttributeError: module 'asyncio' has no attribute 'run'

Python version too old. Update to at least Python 3.7 should fix the issue.

@mateusfccp
Copy link

Has anyone the link for the new Mac versions? I can only find it in App Store, but I have no access to the App Store.

@Blendertom
Copy link

Has anyone the link for the new Mac versions? I can only find it in App Store, but I have no access to the App Store.

Any luck with this?

The best I've been able to do is sideload an .ipa for it, but the experience is not ideal

@mateusfccp
Copy link

Has anyone the link for the new Mac versions? I can only find it in App Store, but I have no access to the App Store.

Any luck with this?

The best I've been able to do is sideload an .ipa for it, but the experience is not ideal

This would have helped me back then, maybe you could provide us with this?

Now I bought a new personal machine and I am able to download it from the App Store, but it always a good idea to have alternative methods.

@Blendertom
Copy link

Now I bought a new personal machine and I am able to download it from the App Store

Downloaded the IPA from https://decrypt.day/ and sideloaded it using sideloadly, https://sideloadly.io/ (this required an apple developer account, free will do)

Now that you have the app installed on your laptop can you try sharing it. Just drag the app from your application folder, upload it and share the link?

Would like to test out if it'll works - your personal data will not be shared as it's in a seperate folder.

@mateusfccp
Copy link

Yes, I can do it.

Version: 7.23.0.100 (1.357417.10)

Disclaimer:
I am sharing this app only because someone specifically requested it. Please note that I am not responsible for the safety or functionality of this executable. Installing and using software from external sources always carries risks, so proceed with caution. Ensure you trust the source and take the necessary precautions to secure your device.

Additionally, since I am hosting this file on my personal cloud drive, it may be removed at any time if I need to reclaim storage space.

https://drive.google.com/file/d/12OiTeOFui0Rx86U4RmSisemtl3QaZeSK/view?usp=share_link

@Blendertom
Copy link

Yes, I can do it.

Thank you! It worked for me - feel free to remove it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment