speereader.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. """
  3. How to run this script.
  4. 1. Install with pip the requests and markdown module
  5. 2. In the browser variable specify your browser to something that can be ran in your shell
  6. 3. In the file variable specify where you want the html file to go.
  7. 4. Put a styles.css file in this directory.
  8. 5. Finally run this script with python.
  9. """
  10. # Make sure you pip install this
  11. import requests
  12. import markdown
  13. import os
  14. from time import gmtime, strftime
  15. # Variables for the user
  16. browser = 'vieb '
  17. Date = str(strftime("%a-%d-%b-%Y-%H-%M-%S"))
  18. file = 'C:\\SGZ_Pro\\Hobbys\\Media\\'+ Date + ".html"
  19. link = input("Link: ")
  20. link = link.lower()
  21. link = link.replace('lbry.ix.tc', 'spee.ch')
  22. link = link.replace('librarian.davidovski.xyz', 'spee.ch')
  23. link = link.replace('madiator.com', 'spee.ch')
  24. link = link.replace('odysee.com', 'spee.ch')
  25. link = link.replace('lbry:/', 'https://spee.ch')
  26. link = link.replace('librarian.davidovski.xyz', 'spee.ch')
  27. md = str(requests.get(link).text.rstrip())
  28. html = markdown.markdown(md)
  29. with open (file, 'w') as f:
  30. f.write(html)
  31. with open(file,'r') as contents:
  32. save = contents.read()
  33. with open(file,'w') as contents:
  34. contents.write("<!DOCTYPE html>\n<head>\n<meta http-equiv='Content-Type' content='text/html;charset=utf-8' />\n<meta name='viewport' content='width=device-width, initial-scale=1' />\n<link rel='stylesheet' href='./styles.css'>")
  35. with open(file,'a') as contents:
  36. contents.write(save)
  37. os.system(browser + file)
  38. print(md)