A command line (CLI) program for monitoring and downloading 8chan threads. Licensed under MIT.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lizard.py 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env python3
  2. import sys
  3. import db_methods
  4. def help_info():
  5. print(""" _.-~` `~-.
  6. _.--~~~---,.__ _.,;; . -=(@'`\\
  7. .-` ``~~~~--~~` ';;; ____)
  8. _.' '. ';;;;; '`_.'
  9. .-~;` `\ ' ';;;;;__.~`
  10. .' .' `'. | / /;''
  11. \/ .---'''``) /'-._____.--'\ \\
  12. _/| (` / /` `\ \__
  13. ', `/- \ \ __/ (_ /-\-\-`
  14. `;'-..___) | `/-\-\-` Lizard
  15. `-. .' the 8chan monitor
  16. `~~~~`` v0.2
  17. Usage: ./lizard [command] [options]
  18. Available commands:
  19. l - Lists all threads in database. Legend: ! - new replies, x - 404'd.
  20. r - Refresh all threads and update database.
  21. rc - Conservative refresh: Tries to refresh only threads which are likely to receive new replies, reducing
  22. unnecessary network activity.
  23. rl - Conservative refresh and list threads.
  24. ro - Conservative refresh and open threads with new replies in browsed.
  25. o - Open threads with new replies in the default browser. Will also update the "new replies"
  26. field accordingly.
  27. oa - Open all threads.
  28. p - Purge (remove) 404'd threads from database.
  29. c - Create new database.
  30. b - Backup current database.
  31. e - Export list of threads. This will create a list of lizard add commands for all threads currently in the
  32. database. Useful for migrating between database versions.
  33. a - Add thread to database. Requires option (URL of the thread). Will also attempt to download
  34. the thread.
  35. d - Remove all instances of a thread (board & number) from the database.
  36. Example: "lizard d b 123" will remove thread >>>/b/123
  37. """)
  38. exit()
  39. def main():
  40. n = len(sys.argv)
  41. if n < 2: help_info()
  42. command = sys.argv[1]
  43. if n == 2:
  44. if command == 'l':
  45. db_methods.list_threads()
  46. elif command == 'r':
  47. db_methods.refresh_all_threads()
  48. elif command == 'rc':
  49. db_methods.refresh_all_threads(conservative=True)
  50. elif command == 'rl':
  51. db_methods.refresh_all_threads(conservative=True)
  52. db_methods.list_threads()
  53. elif command == 'ro':
  54. db_methods.refresh_all_threads(conservative=True)
  55. db_methods.open_threads_with_new_replies()
  56. elif command == 'o':
  57. db_methods.open_threads_with_new_replies()
  58. elif command == 'oa':
  59. db_methods.open_all_threads()
  60. elif command == 'p':
  61. db_methods.remove_404_threads()
  62. elif command == 'c':
  63. db_methods.create_new_database()
  64. elif command == 'b':
  65. db_methods.backup_database()
  66. elif command == 'e':
  67. db_methods.export_thread_list()
  68. else:
  69. help_info()
  70. elif n == 3:
  71. if command == 'a':
  72. db_methods.add_thread_to_db(sys.argv[2])
  73. else:
  74. help_info()
  75. elif n == 4:
  76. if command == 'd':
  77. db_methods.remove_thread_by_id(sys.argv[2], sys.argv[3])
  78. else:
  79. help_info()
  80. else:
  81. help_info()
  82. if __name__ == '__main__':
  83. main()