forked from Exceen/4chan-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added gui files, made many improvements
- Loading branch information
1 parent
4426aef
commit c869462
Showing
5 changed files
with
200 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import PySimpleGUI as sg | ||
import subprocess | ||
import threading | ||
|
||
def run_picrel_script(url, use_names, reload_queue, use_titles, monitor_thread): | ||
# Define the command to execute the picrel script | ||
cmd = ['python', 'picrel.py', url] | ||
|
||
if use_names: | ||
cmd.append('-n') | ||
if reload_queue: | ||
cmd.append('-r') | ||
if use_titles: | ||
cmd.append('-t') | ||
if monitor_thread: | ||
cmd.append('-m') | ||
|
||
# Execute the picrel script | ||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) | ||
|
||
while True: | ||
line = process.stdout.readline() | ||
if not line: | ||
break | ||
print(line.strip()) | ||
|
||
process.wait() | ||
|
||
def run_script(): | ||
# Disable the 'Run' button while the script is running | ||
window['-RUN-'].update(disabled=True) | ||
|
||
# Clear the output before running the script | ||
window['-OUTPUT-'].update('') | ||
|
||
# Get the selected values from the GUI | ||
url = values['-THREAD_URL-'] | ||
use_names = values['-USE_NAMES-'] | ||
reload_queue = values['-RELOAD-'] | ||
use_titles = values['-TITLE-'] | ||
monitor_thread = values['-MONITOR-'] | ||
|
||
# Create a separate thread for running the picrel script | ||
thread = threading.Thread(target=run_picrel_script, args=(url, use_names, reload_queue, use_titles, monitor_thread)) | ||
thread.start() | ||
|
||
def exit_script(): | ||
# Close the window | ||
window.close() | ||
|
||
# Set the color theme for the GUI | ||
sg.theme('GreenMono') | ||
sg.set_options(font=('Arial', 14)) | ||
|
||
# Create the GUI layout | ||
layout = [ | ||
[sg.Text('Thread URL or Queue file'), sg.Input(key='-THREAD_URL-')], | ||
[sg.Checkbox('Use Thread Names', key='-USE_NAMES-')], | ||
[sg.Checkbox('Reload queue file', key='-RELOAD-')], | ||
[sg.Checkbox('Use Media Titles', key='-TITLE-')], | ||
[sg.Checkbox('Keep monitoring the thread', key='-MONITOR-')], | ||
[sg.Button('Run', key='-RUN-', size=(10, 1)), sg.Button('Exit', key='-EXIT-', size=(10, 1))], | ||
[sg.Output(size=(80, 10), key='-OUTPUT-')] | ||
] | ||
|
||
# Create the window | ||
window = sg.Window('4chan-picrel / Media downloader', layout) | ||
|
||
# Event loop | ||
while True: | ||
event, values = window.read() | ||
if event == sg.WINDOW_CLOSED or event == '-EXIT-': | ||
exit_script() | ||
break | ||
elif event == '-RUN-': | ||
run_script() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import PySimpleGUI as sg | ||
import subprocess | ||
import threading | ||
import sys | ||
|
||
def run_queue_creator(board, query, queuefile, naming, thread_url=None, api_url=None, directory=False): | ||
# Define the command to execute the queue-creator script | ||
cmd = ['python', 'queue-creator.py', '-b', board, '-q', query, '-f', queuefile, '-n', naming] | ||
|
||
if thread_url: | ||
cmd.extend(['-u', thread_url]) | ||
|
||
if api_url: | ||
cmd.extend(['-a', api_url]) | ||
|
||
if directory: | ||
cmd.append('-d') | ||
|
||
# Execute the queue-creator script | ||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) | ||
|
||
while True: | ||
line = process.stdout.readline() | ||
if not line: | ||
break | ||
print(line.strip()) | ||
|
||
process.wait() | ||
|
||
if process.returncode == 0: | ||
print('Queue file created:', queuefile) | ||
else: | ||
print('Error:', process.stderr.read()) | ||
|
||
def create_queue_gui(board, query, queuefile, naming, thread_url=None, api_url=None, directory=False): | ||
# Create a separate thread for running the queue-creator script | ||
thread = threading.Thread(target=run_queue_creator, args=(board, query, queuefile, naming, thread_url, api_url, directory)) | ||
thread.start() | ||
|
||
# Set the theme and font for the window | ||
sg.theme('GreenMono') | ||
sg.set_options(font=('Arial', 14)) | ||
|
||
# Define the layout | ||
layout = [ | ||
[sg.Text('Board name:'), sg.Input(key='-BOARD-')], | ||
[sg.Text('Search terms:'), sg.Input(key='-QUERY-')], | ||
[sg.Text('Name of the Queue File:'), sg.Input(key='-QUEUEFILE-'), sg.FileSaveAs()], | ||
[sg.Text('Search name:'), sg.Input(key='-NAMING-')], | ||
#[sg.Text('Thread URL (optional):'), sg.Input(key='-THREADURL-')], | ||
#[sg.Text('API URL (optional):'), sg.Input(key='-APIURL-')], | ||
[sg.Checkbox('Save queue file in Board Directory', key='-DIRECTORY-')], | ||
[sg.Button('Create Queue File'), sg.Button('Exit')], | ||
[sg.Output(size=(60, 10), key='-OUTPUT-')] | ||
] | ||
|
||
# Create the window | ||
window = sg.Window('4chan-picrel / Queue File Creator', layout) | ||
|
||
# Event loop | ||
while True: | ||
event, values = window.read() | ||
if event == sg.WINDOW_CLOSED or event == 'Exit': | ||
break | ||
elif event == 'Create Queue': | ||
board = values['-BOARD-'] | ||
query = values['-QUERY-'] | ||
queuefile = values['-QUEUEFILE-'] | ||
naming = values['-NAMING-'] | ||
#thread_url = values['-THREADURL-'] | ||
#api_url = values['-APIURL-'] | ||
directory = values['-DIRECTORY-'] | ||
|
||
if not queuefile: | ||
print('Please specify a queue file.') | ||
elif not board: | ||
print('Please specify a board.') | ||
elif not query: | ||
print('Please specify a query.') | ||
elif not naming: | ||
print('Please specify a naming convention.') | ||
else: | ||
#print('Creating queue file...') | ||
#create_queue_gui(board, query, queuefile, naming, thread_url, api_url, directory) | ||
create_queue_gui(board, query, queuefile, naming, directory) | ||
|
||
# Close the window | ||
window.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
beautifulsoup4==4.12.2 | ||
Django==4.2.1 | ||
asgiref==3.7.2 | ||
beautifulsoup4==4.12.2 | ||
Django==4.2.5 | ||
PySimpleGUI==4.60.5 | ||
soupsieve==2.5 | ||
sqlparse==0.4.4 | ||
tzdata==2023.3 |