Skip to content

Instantly share code, notes, and snippets.

@ibnux
Created January 23, 2021 16:01
Show Gist options
  • Save ibnux/e358ff9f39eb3c8d21529c3d440170db to your computer and use it in GitHub Desktop.
Save ibnux/e358ff9f39eb3c8d21529c3d440170db to your computer and use it in GitHub Desktop.
Python script for Upload Screenshoot Kindle to telegram
import os, requests
# Your kindle must be jailbreak then install SSH and python
# https://www.mobileread.com/forums/forumdisplay.php?f=140
# save script on /mnt/us/upload.py
# run: mntroot rw
# edit /etc/crontab/root
# add: */5 7-22 * * * * python /mnt/us/upload.py
# every 5 minuts it will check screenshoot, upload it, and delete it
# you can run python /mnt/us/upload.py to check it is it working
# https://t.me/botfather
botToken = '139367:AAED0ZpygDgNtng'
# chat wit your bot, so bot can send you message
# https://www.google.com/search?q=hotw+to+get+my+telegram+id
chatID = '1234321'
def scanDir(path):
print(path)
for file in os.listdir(path):
print(file)
pathf = os.path.join(path, file)
if file.startswith("screenshot_"):
with open(pathf, 'rb') as f:
r = requests.post(
'https://api.telegram.org/bot'+botToken+'/sendPhoto?chat_id='+chatID+'&caption='+file,
files={'photo': f})
print(r.text)
# Delete if success
if '"ok":true' in r.text:
os.remove(pathf)
if __name__ == '__main__':
scanDir('/mnt/us/')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment