Browse Source

Fixed #38

master
Abrax 3 years ago
parent
commit
b85f598398
4 changed files with 16 additions and 7 deletions
  1. 1
    0
      README.md
  2. 7
    3
      lizard/__init__.py
  3. 2
    2
      lizard/db_methods.py
  4. 6
    2
      lizard/web_methods.py

+ 1
- 0
README.md View File

@@ -21,6 +21,7 @@ This version changes syntax for some commands:
* `lizard r` does conservative refresh
* Refresh all threads: `lizard ra` instead of `lizard r`
* Changed packaging system: Now building wheels which are compatible with `pip`
* Basic Tor support: `lizard to` will open the threads using the onion domain.

### 0.2 (current)
* Help message now shows version. (issue #24)

+ 7
- 3
lizard/__init__.py View File

@@ -33,6 +33,7 @@ Available commands:
o - Open threads with new replies in the default browser. Will also update the "new replies"
field accordingly.
oa - Open all threads.
to - Open threads with new replies, using the onion URL. Use this if you are using Tor.
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
@@ -67,13 +68,16 @@ def main():
elif command == 'ro':
db_methods.check_database()
db_methods.refresh_all_threads(conservative=True)
db_methods.open_threads(True)
db_methods.open_threads(only_threads_with_new_replies=True)
elif command == 'o':
db_methods.check_database()
db_methods.open_threads(True)
db_methods.open_threads(only_threads_with_new_replies=True)
elif command == 'oa':
db_methods.check_database()
db_methods.open_threads(False)
db_methods.open_threads(only_threads_with_new_replies=False)
elif command == 'to':
db_methods.check_database()
db_methods.open_threads(only_threads_with_new_replies=True, use_onion_link=True)
elif command == 'p':
db_methods.check_database()
db_methods.remove_404_threads()

+ 2
- 2
lizard/db_methods.py View File

@@ -164,7 +164,7 @@ def refresh_all_threads(conservative=False):
print('Done!')


def open_threads(only_threads_with_new_replies=True):
def open_threads(only_threads_with_new_replies=True, use_onion_link=False):
if not only_threads_with_new_replies:
threads = Thread.select()
else:
@@ -173,7 +173,7 @@ def open_threads(only_threads_with_new_replies=True):
print('Opening {} threads in browser.'.format(len(threads)))

for t in threads:
thread_url = web_methods.generate_thread_html_url(t.board, t.thread_no)
thread_url = web_methods.generate_thread_html_url(t.board, t.thread_no, use_onion_link=use_onion_link)
if t.oldest_new_reply:
thread_url += '#{}'.format(t.oldest_new_reply)


+ 6
- 2
lizard/web_methods.py View File

@@ -77,8 +77,12 @@ def generate_thread_json_url(board, thread_no):
return url


def generate_thread_html_url(board, thread_no):
url = 'https://8ch.net/{}/res/{}.html'.format(board, thread_no)
def generate_thread_html_url(board, thread_no, use_onion_link=False):
if use_onion_link:
url = 'http://oxwugzccvk3dk6tj.onion/{}/res/{}.html'.format(board, thread_no)
else:
url = 'https://8ch.net/{}/res/{}.html'.format(board, thread_no)

return url



Loading…
Cancel
Save