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.
 
 

123 lines
5.1 KiB

#!/usr/bin/env python3
import sys
import webbrowser
import pkg_resources
from lizard import db_methods
version = pkg_resources.require("lizard")[0].version
def help_info():
print(""" _.-~` `~-.
_.--~~~---,.__ _.,;; . -=(@'`\\
.-` ``~~~~--~~` ';;; ____)
_.' '. ';;;;; '`_.'
.-~;` `\ ' ';;;;;__.~`
.' .' `'. | / /;''
\/ .---'''``) /'-._____.--'\ \\
_/| (` / /` `\ \__
', `/- \ \ __/ (_ /-\-\-`
`;'-..___) | `/-\-\-` Lizard
`-. .' the 8chan monitor
`~~~~`` v{}
Usage: lizard [command] [options]
Available commands:
la - Lists all threads in database. Legend: ! - new replies, x - 404'd, Y - >(You).
l - Lists only threads that have activity.
r - Refresh threads which are likely to receive new replies (to reduce unnecessary network activity). Use tr for
onion link.
ra - Refresh all threads and update database. Use tra for onion link.
rl - Conservative refresh and list threads. Use trl for onion link.
ro - Conservative refresh and open threads with new replies in browsed. Use tro for onion link.
o - Open threads with new replies in the default browser. Will also update the "new replies"
field accordingly. Use to for onion link.
oa - Open all threads. Use toa for onion link.
tor - Same as to but also opens the Tor CAPTCHA page for convenience.
p - Purge (remove) 404'd threads from database.
b - Backup current database.
e - Export list of threads. This will create a list of lizard add commands for all threads currently in the
database. Useful for migrating between database versions.
a - Add thread to database. Requires option (URL of the thread). Will also attempt to download
the thread. Supports onion links.
d - Remove all instances of a thread (board & number) from the database.
Example: "lizard d b 123" will remove thread >>>/b/123
create - Create new database.
""".format(version))
exit()
def main():
n = len(sys.argv)
if n < 2:
help_info()
command = sys.argv[1]
onion = (command[0] == 't') # The tor version of each command starts with t
if n == 2:
if command == 'la':
db_methods.check_database()
db_methods.list_threads(interesting_only=False)
elif command == 'l':
db_methods.check_database()
db_methods.list_threads(interesting_only=True)
elif (command == 'r') or (command == 'tr'):
db_methods.check_database()
db_methods.refresh_all_threads(conservative=True, use_onion_link=onion)
elif (command == 'ra') or (command == 'tra'):
db_methods.check_database()
db_methods.refresh_all_threads(use_onion_link=onion)
elif (command == 'rl') or (command == 'trl'):
db_methods.check_database()
db_methods.refresh_all_threads(conservative=True, use_onion_link=onion)
db_methods.list_threads(interesting_only=True)
elif (command == 'ro') or (command == 'tro'):
db_methods.check_database()
db_methods.refresh_all_threads(conservative=True, use_onion_link=onion)
db_methods.open_threads(only_threads_with_new_replies=True)
elif (command == 'o') and (command == 'to'):
db_methods.check_database()
db_methods.open_threads(only_threads_with_new_replies=True, use_onion_link=onion)
elif (command == 'oa') and (command == 'toa'):
db_methods.check_database()
db_methods.open_threads(only_threads_with_new_replies=False, use_onion_link=onion)
elif command == 'tor':
db_methods.check_database()
db_methods.open_threads(only_threads_with_new_replies=True, use_onion_link=True)
webbrowser.open('http://oxwugzccvk3dk6tj.onion/dnsbls_bypass.php')
elif command == 'p':
db_methods.check_database()
db_methods.remove_404_threads()
elif command == 'create':
db_methods.create_new_database()
db_methods.check_database() # In case the DB creation is wrong
elif command == 'b':
# Not checking DB here, because there might be good reason to backup an invalid DB (eg. version conflict)
db_methods.backup_database()
elif command == 'e':
db_methods.check_database()
db_methods.export_thread_list()
else:
help_info()
elif n == 3:
if command == 'a':
db_methods.check_database()
db_methods.add_thread_to_db(sys.argv[2])
else:
help_info()
elif n == 4:
if command == 'd':
db_methods.check_database()
db_methods.remove_thread_by_id(sys.argv[2], sys.argv[3])
else:
help_info()
else:
help_info()
if __name__ == '__main__':
main()