Skip to content

Commit

Permalink
- fixed in CLI
Browse files Browse the repository at this point in the history
- trying to get Android to work (it won't lmao)
  • Loading branch information
EchterAlsFake committed Dec 29, 2024
1 parent 72fe925 commit 5848465
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 86 deletions.
15 changes: 9 additions & 6 deletions Porn_Fetch_CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
from base_api.modules.download import *
from base_api.modules.progress_bars import *
from base_api.base import Core
from colorama import init
from rich import print as rprint
from rich.markdown import Markdown
from rich.progress import Progress, BarColumn, TextColumn, SpinnerColumn, TimeElapsedColumn, TimeRemainingColumn
from colorama import *
from hue_shift import return_color

logger = setup_logging()
init(autoreset=True)
Expand All @@ -34,9 +35,11 @@ def __init__(self):
self.result_limit = None
self.directory_system = None
self.output_path = None
self.progress_thread = None
self.quality = None
self.semaphore = None
self.retries = None
self.conf = None
self.timeout = None
self.workers = None
self.delay = None
Expand Down Expand Up @@ -166,7 +169,7 @@ def load_user_settings(self):
self.retries = int(self.conf.get("Performance", "retries"))
self.semaphore = threading.Semaphore(int(self.conf.get("Performance", "semaphore")))
self.quality = self.conf.get("Video", "quality")
self.output_path = correct_output_path(output_path=self.conf.get("Video", "output_path"))
self.output_path = self.conf.get("Video", "output_path")
self.directory_system = True if self.conf.get("Video", "directory_system") == "1" else False
self.skip_existing_files = True if self.conf.get("Video", "skip_existing_files") == "true" else False
self.result_limit = int(self.conf.get("Video", "search_limit"))
Expand Down Expand Up @@ -197,8 +200,8 @@ def save_user_settings(self):
while True:
quality_color = { # Highlight the current quality option in yellow
"Best": Fore.LIGHTYELLOW_EX if self.quality == "best" else Fore.LIGHTWHITE_EX,
"Half": Fore.LIGHTYELLOW_EX if self.quality == "balf" else Fore.LIGHTWHITE_EX,
"Worst": Fore.LIGHTYELLOW_EX if self.quality == "borst" else Fore.LIGHTWHITE_EX
"Half": Fore.LIGHTYELLOW_EX if self.quality == "half" else Fore.LIGHTWHITE_EX,
"Worst": Fore.LIGHTYELLOW_EX if self.quality == "worst" else Fore.LIGHTWHITE_EX
}
threading_mode_color = { # Highlight the current threading mode in yellow
"threaded": Fore.LIGHTYELLOW_EX if self.threading_mode == "threaded" else Fore.LIGHTWHITE_EX,
Expand Down Expand Up @@ -528,10 +531,10 @@ def callback_wrapper(pos, total):
'-loglevel', 'error']
ff = FfmpegProgress(cmd)
for progress in ff.run_command_with_progress():
pass
logger.debug(f"Converting progress: {progress}")

os.remove(f"{output_path}_.tmp")
write_tags(path=output_path, data=load_video_attributes(video, data_mode=1))
write_tags(path=output_path, data=load_video_attributes(video))
else:
logger.debug("FFMPEG features disabled, writing tags and converting the video won't be available!")

Expand Down
137 changes: 92 additions & 45 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,79 @@
import sys
import time
import random
import shutil
import tarfile
import os.path
import zipfile
import argparse
import markdown
import traceback
import requests.exceptions
import src.frontend.resources # Your IDE may tell you that this is an unused import statement, but that is WRONG!

from phub import consts
from threading import Event
from io import TextIOWrapper
from base_api.base import Core
from itertools import islice, chain
from hqporner_api.api import Sort as hq_Sort
from base_api.modules import consts as bs_consts

from src.backend.shared_gui import *
from src.backend.class_help import *
from src.backend.shared_functions import *
from src.backend.log_config import setup_logging
from src.frontend.ui_form_license import Ui_SetupLicense
from src.frontend.ui_form_desktop import Ui_PornFetch_Desktop
from src.frontend.ui_form_android import Ui_PornFetch_Android
from src.frontend.ui_form_range_selector import Ui_PornFetchRangeSelector
from src.frontend.ui_form_install_dialog import Ui_SetupInstallDialog
from src.frontend.ui_form_keyboard_shortcuts import Ui_KeyboardShortcuts

from PySide6.QtCore import (QFile, QTextStream, Signal, QRunnable, QThreadPool, QObject, QSemaphore, Qt, QLocale,
QTranslator, QCoreApplication, QSize)
from PySide6.QtWidgets import QWidget, QApplication, QTreeWidgetItem, QButtonGroup, QFileDialog, QHeaderView
from PySide6.QtGui import QIcon, QFont, QFontDatabase, QPixmap, QShortcut
import http.client
import json


do_not_log = False
def send_error_log(message):
"""
This function is made for the Android development of Porn Fetch and is used for debugging.
You can, of course, change or remove it, but I wouldn't recommend it.
"""

if do_not_log is False:
url = "192.168.2.139:8000"
endpoint = "/error-log/"
data = json.dumps({"message": message})
headers = {"Content-type": "application/json"}

conn = http.client.HTTPConnection(url)

try:
conn.request("POST", endpoint, data, headers)
response = conn.getresponse()

if response.status == 200:
print("Error log sent successfully")
else:
print(f"Failed to send error log: Status {response.status}, Reason: {response.reason}")

conn.close()
except Exception as e:
print(f"Request failed: {e}")

send_error_log("Hi")

try:
import sys
import time
import random
import shutil
import tarfile
import os.path
import zipfile
import argparse
import markdown
import traceback
import requests.exceptions
import src.frontend.resources # Your IDE may tell you that this is an unused import statement, but that is WRONG!

from phub import consts
from threading import Event
from io import TextIOWrapper
from base_api.base import Core
from itertools import islice, chain
from hqporner_api.api import Sort as hq_Sort
from base_api.modules import consts as bs_consts

from src.backend.shared_gui import *
from src.backend.class_help import *
from src.backend.shared_functions import *

from src.backend.log_config import setup_logging
from src.frontend.ui_form_license import Ui_SetupLicense
from src.frontend.ui_form_desktop import Ui_PornFetch_Desktop
from src.frontend.ui_form_android import Ui_PornFetch_Android
from src.frontend.ui_form_range_selector import Ui_PornFetchRangeSelector
from src.frontend.ui_form_install_dialog import Ui_SetupInstallDialog
from src.frontend.ui_form_keyboard_shortcuts import Ui_KeyboardShortcuts

from PySide6.QtCore import (QFile, QTextStream, Signal, QRunnable, QThreadPool, QObject, QSemaphore, Qt, QLocale,
QTranslator, QCoreApplication, QSize, QTimer)
from PySide6.QtWidgets import QWidget, QApplication, QTreeWidgetItem, QButtonGroup, QFileDialog, QHeaderView
from PySide6.QtGui import QIcon, QFont, QFontDatabase, QPixmap, QShortcut

except Exception:
error = traceback.format_exc()
send_error_log(error)

"""
Copyright (C) 2023-2024 Johannes Habel
Expand All @@ -59,7 +99,7 @@

__license__ = "GPL 3"
__version__ = "3.5"
__build__ = "desktop" # android or desktop
__build__ = "android" # android or desktop
__author__ = "Johannes Habel"
__next_release__ = "3.5"
total_segments = 0
Expand Down Expand Up @@ -177,12 +217,16 @@ def show_android_startup_or_main(self):
self.close()

if __build__ == "android":
pass # TODO
self.show_main()

else:
self.show_install_dialog()


def show_install_dialog(self):
if sys.platform == "darwin":
self.show_main() # Installation not supported on macOS

if self.conf["Setup"]["install"] == "unknown":
self.install_widget = InstallDialog()
self.install_widget.show()
Expand Down Expand Up @@ -1034,7 +1078,6 @@ def __init__(self, parent=None, start_installation=False, app_name="Porn Fetch")

self.conf = ConfigParser()
self.conf.read("config.ini")

if __build__ == "android":
self.ui = Ui_PornFetch_Android()
self.ui.setupUi(self)
Expand Down Expand Up @@ -2288,12 +2331,15 @@ def switch_to_all_progress_bars(self):


def main():
send_error_log("Running in main function")
setup_config_file()
send_error_log("Finished setting up configuration file")
app = QApplication(sys.argv)
app.setStyle("Fusion")
conf = ConfigParser()
conf.read("config.ini")
language = conf["UI"]["language"]
send_error_log("3")

if language == "system":
# Get the system's locale
Expand All @@ -2302,13 +2348,13 @@ def main():

else:
language_code = language

send_error_log("Got language code")
# Try loading the specific regional translation
path = f":/translations/translations/{language_code}.qm"
translator = QTranslator(app)
if translator.load(path):
logger.debug(f"Startup: [1/5] {language_code} translation loaded")

send_error_log("Applied translation")
else:
# Try loading a more general translation if specific one fails
general_language_code = language_code.split('_')[0]
Expand All @@ -2319,16 +2365,16 @@ def main():
logger.debug(f"Failed to load {language_code} translation")

app.installTranslator(translator)

send_error_log("Installed translation")
file = QFile(":/style/stylesheets/stylesheet.qss")
file.open(QFile.OpenModeFlag.ReadOnly | QFile.OpenModeFlag.Text)
stream = QTextStream(file)
app.setStyleSheet(stream.readAll())

send_error_log("Set main stylesheet")
if __build__ == "android":
font = QFont("arial", 12)
app.setFont(font)

send_error_log("Applied Arial font")
if conf["UI"]["custom_font"] == "true":
font_id = QFontDatabase.addApplicationFont(":/fonts/graphics/JetBrainsMono-Regular.ttf")
if font_id == -1:
Expand All @@ -2339,9 +2385,10 @@ def main():
font_family = QFontDatabase.applicationFontFamilies(font_id)[0]
logger.info(f"Using custom font -->: {font_family}")
app.setFont(QFont(font_family))

send_error_log("Loaded custom font")
widget = License() # Starts License widget and checks if license was accepted.
widget.check_license_and_proceed()
send_error_log("Did License stuff yk")
"""
The following exceptions are just general exceptions to handle some basic errors. They are not so relevant for
most cases.
Expand Down
2 changes: 1 addition & 1 deletion src/backend/log_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
android = False
android = True

def setup_logging():
# Check if running on Android, either from platform or a flag
Expand Down
8 changes: 2 additions & 6 deletions src/backend/shared_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
from mutagen.mp4 import MP4, MP4Cover
from phub import Client, errors, Video
from phub.modules import download as download
from colorama import Fore
from hue_shift import return_color, reset
from datetime import datetime
from configparser import ConfigParser
from hqporner_api import Client as hq_Client, Video as hq_Video
from eporner_api import Client as ep_Client, Video as ep_Video
Expand Down Expand Up @@ -85,16 +82,15 @@
"""

logger = logging.getLogger(__name__)
do_not_log = True

do_not_log = False
def send_error_log(message):
"""
This function is made for the Android development of Porn Fetch and is used for debugging.
You can, of course, change or remove it, but I wouldn't recommend it.
"""

if do_not_log is False:
url = "192.168.0.19:8000"
url = "192.168.2.139:8000"
endpoint = "/error-log/"
data = json.dumps({"message": message})
headers = {"Content-type": "application/json"}
Expand Down
4 changes: 2 additions & 2 deletions src/build/requirements_android.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Command:
pyside6-android-deploy --wheel-pyside PySide6-6.8.0-6.8.0-cp311-cp311-android_aarch64.whl --wheel-shiboken shiboken6-6.8.0-6.8.0-cp311-cp311-android_aarch64.whl --name=test --ndk-path /home/asuna/.pyside6_android_deploy/android-ndk/android-ndk-r26b/ --sdk-path /home/asuna/.pyside6_android_deploy/android-sdk/
pyside6-android-deploy --wheel-pyside PySide6-6.8.0a1-6.8.1-cp311-cp311-android_aarch64.whl --wheel-shiboken shiboken6-6.8.0a1-6.8.1-cp311-cp311-android_aarch64.whl --name=test --ndk-path /home/asuna/.pyside6_android_deploy/android-ndk/android-ndk-r26b/ --sdk-path /home/asuna/.pyside6_android_deploy/android-sdk/

requirements:
,charset-normalizer==2.1.1,git+https://github.com/EchterAlsFake/PHUB,idna,urllib3,certifi,hue_shift,markdown,colorama,requests,git+https://github.com/EchterAlsFake/hqporner_api,ffmpeg-progress-yield,tqdm,git+https://github.com/EchterAlsFake/eporner_api,git+https://github.com/EchterAlsFake/xnxx_api,git+https://github.com/EchterAlsFake/xvideos_api,beautifulsoup4,mutagen,git+https://github.com/EchterAlsFake/eaf_base_api,httpx,httpcore,h11,certifi,idna,sniffio,git+https://github.com/EchterAlsFake/spankbang_api
,charset-normalizer==2.1.1,git+https://github.com/EchterAlsFake/PHUB,idna,urllib3,certifi,hue_shift,markdown,colorama,requests,git+https://github.com/EchterAlsFake/hqporner_api,ffmpeg-progress-yield,tqdm,git+https://github.com/EchterAlsFake/eporner_api,git+https://github.com/EchterAlsFake/xnxx_api,git+https://github.com/EchterAlsFake/xvideos_api,beautifulsoup4,mutagen,git+https://github.com/EchterAlsFake/eaf_base_api,httpx,httpcore,h11,certifi,idna,sniffio,git+https://github.com/EchterAlsFake/spankbang_api,json5

package domain:
com.pornfetch
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -27944,11 +27944,11 @@
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x07\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x07\x0a\x00\x00\x00\x00\x00\x01\x00\x06m&\
\x00\x00\x01\x94\x0e\x16\xa4\xcd\
\x00\x00\x01\x94\x0f`\xa8\x9b\
\x00\x00\x07\x1a\x00\x04\x00\x00\x00\x01\x00\x06\x83\xfa\
\x00\x00\x01\x94\x0e\x16\xa47\
\x00\x00\x01\x94\x0f`\xa7\xdd\
\x00\x00\x070\x00\x00\x00\x00\x00\x01\x00\x06\xabo\
\x00\x00\x01\x94\x0e\x16\xa4\x83\
\x00\x00\x01\x94\x0f`\xa8:\
\x00\x00\x06\xa6\x00\x02\x00\x00\x00\x01\x00\x00\x00\x0b\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x06\xb8\x00\x04\x00\x00\x00\x01\x00\x027\xfc\
Expand Down
Loading

0 comments on commit 5848465

Please sign in to comment.