Skip to content

Instantly share code, notes, and snippets.

@deadjakk
Created March 2, 2022 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deadjakk/ed811341c14ea63a51bf5dd1b38f640e to your computer and use it in GitHub Desktop.
Save deadjakk/ed811341c14ea63a51bf5dd1b38f640e to your computer and use it in GitHub Desktop.
downloads all files or files that contain a given substring from the remarkable 2 tablet
#!/usr/bin/python3
# @deadjakk
# to use: just plug in remarkable 2 tablet, go to settings > storage > enable web application
# then run
# python3 ./remarkable-downloader.py # this downloads literally everything as a pdf
# alternatively, adding a word as an argument will only download files with that word in the name
# python3 ./remarkable-downloader.py "math-notes" # this downloads math-notes.pdf
# this could be cleaner... but I no longer use/have a remarkable 2 so I probably won't bother
# probably need to run these as well:
# pip install glob
# pip install requests
import glob
import json
import requests as rq
from os import system
from sys import exit,argv
URL = "http://10.11.99.1/"
DOWNLOAD_FMT=URL+"download/{}/placeholder"
def main(torun):
for uuid in torun:
print("downloading {} at".format(uuid["visibleName"]),DOWNLOAD_FMT.format(uuid["filename"]))
url = (DOWNLOAD_FMT.format(uuid["filename"]))
r = rq.get(url)
print("response: {}".format(r.status_code))
if r.status_code == 200:
local_filename = uuid["visibleName"].replace(" ","_")+".pdf"
print("length of {} {}".format(len(r.content),local_filename))
f = open(local_filename, 'wb')
for chunk in r.iter_content(chunk_size=512 * 1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.close()
if __name__ == '__main__':
torun=[]
search = None
res = system("rm *.metadata; scp remarkable:~/.local/share/remarkable/xochitl/*.metadata .")
if res != 0:
print("error: scp failed")
if len(argv) == 2:
search = argv[1]
print("searching for {}".format(search))
for mfile in glob.glob("*.metadata"):
with open(mfile,'r') as fh:
mdata = fh.read()
metadata_json = json.loads(mdata)
#print (metadata_json)
if metadata_json["type"] == "DocumentType":
metadata_json["filename"] = mfile.split(".")[0]
# print(metadata_json["filename"],metadata_json["visibleName"])
if not search:
torun.append(metadata_json)
if search and search.lower() in metadata_json["visibleName"].lower():
print("found file you wanted...")
torun.append(metadata_json)
print("removing metadata")
system("rm *.metadata")
main(torun)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment