Skip to content

Commit

Permalink
support path
Browse files Browse the repository at this point in the history
  • Loading branch information
datawhores committed Mar 21, 2024
1 parent 8d75ae1 commit f03a5f6
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 19 deletions.
1 change: 0 additions & 1 deletion ofscraper/api/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
wait_random,
)

import ofscraper.classes.sessionbuilder as sessionbuilder
import ofscraper.utils.constants as constants
import ofscraper.utils.progress as progress_utils
import ofscraper.utils.sems as sems
Expand Down
2 changes: 2 additions & 0 deletions ofscraper/const/binary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MP4_DECRYPT = "mp4decrypt"
FFMPEG_DECRYPT = "ffmpeg"
3 changes: 1 addition & 2 deletions ofscraper/download/alt_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import ofscraper.download.common.keyhelpers as keyhelpers
import ofscraper.utils.args.read as read_args
import ofscraper.utils.cache as cache
import ofscraper.utils.config.data as config_data
import ofscraper.utils.constants as constants
import ofscraper.utils.dates as dates
import ofscraper.utils.settings as settings
Expand Down Expand Up @@ -97,7 +96,7 @@ async def handle_result(sharedPlaceholderObj, ele, audio, video, username, model
temp_path.unlink(missing_ok=True)
t = subprocess.run(
[
config_data.get_ffmpeg(),
settings.get_ffmpeg(),
"-i",
str(video["path"]),
"-i",
Expand Down
4 changes: 2 additions & 2 deletions ofscraper/download/alt_downloadbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import ofscraper.download.common.keyhelpers as keyhelpers
import ofscraper.utils.args.read as read_args
import ofscraper.utils.cache as cache
import ofscraper.utils.config.data as config_data
import ofscraper.utils.constants as constants
import ofscraper.utils.dates as dates
import ofscraper.utils.settings as settings
from ofscraper.download.common.common import (
addLocalDir,
check_forced_skip,
Expand Down Expand Up @@ -85,7 +85,7 @@ async def handle_result(sharedPlaceholderObj, ele, audio, video, username, model
temp_path.unlink(missing_ok=True)
t = subprocess.run(
[
config_data.get_ffmpeg(),
settings.get_ffmpeg(),
"-i",
str(video["path"]),
"-i",
Expand Down
2 changes: 1 addition & 1 deletion ofscraper/download/common/keyhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def un_encrypt(item, c, ele, input_=None):
)
r = subprocess.run(
[
config_data.get_mp4decrypt(),
settings.get_mp4decrypt(),
"--key",
key,
str(item["path"]),
Expand Down
5 changes: 3 additions & 2 deletions ofscraper/prompts/prompt_groups/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import ofscraper.prompts.prompt_validators as prompt_validators
import ofscraper.prompts.promptConvert as promptClasses
import ofscraper.utils.config.data as data
import ofscraper.utils.settings as settings


def mp4_prompt():
Expand All @@ -62,7 +63,7 @@ def mp4_prompt():
https://www.bento4.com/documentation/mp4decrypt/
""",
"default": data.get_mp4decrypt(),
"default": settings.get_mp4decrypt(),
},
]
)
Expand All @@ -88,7 +89,7 @@ def ffmpeg_prompt():
https://ffmpeg.org/download.html
""",
"default": data.get_ffmpeg(),
"default": settings.get_ffmpeg(),
},
]
)
Expand Down
5 changes: 3 additions & 2 deletions ofscraper/prompts/prompt_groups/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import ofscraper.utils.config.schema as schema
import ofscraper.utils.constants as constants
import ofscraper.utils.paths.common as common_paths
import ofscraper.utils.settings as settings
import ofscraper.utils.system.system as system

console = Console()
Expand Down Expand Up @@ -292,7 +293,7 @@ def binary_config():
prompt_validators.mp4decryptpathvalidator(),
prompt_validators.mp4decryptexecutevalidator(),
),
"default": data.get_mp4decrypt(),
"default": settings.get_mp4decrypt(),
"option_instruction": """
Certain content requires decryption to process please provide the full path to mp4decrypt
""",
Expand All @@ -309,7 +310,7 @@ def binary_config():
"option_instruction": """
Certain content requires decryption to process please provide the full path to ffmpeg
""",
"default": data.get_ffmpeg(),
"default": settings.get_ffmpeg(),
},
],
altx=funct,
Expand Down
6 changes: 5 additions & 1 deletion ofscraper/utils/args/areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ def get_download_area():
"Stories",
"Purchased",
"Profile",
"Labels",
]
if len(read_args.retriveArgs().download_area) == 0:
post = set(read_args.retriveArgs().posts)
else:
post = set(read_args.retriveArgs().download_area)
if "All" in post:
post.update(set(all_choices))
elif "Labels*" or "Labels+":
post.update(set(all_choices))
post.update({"Labels"})
post.discard("Labels*")
post.discard("Laabels+")
return list(
filter(
lambda x: x != "All"
Expand Down
8 changes: 6 additions & 2 deletions ofscraper/utils/args/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ def posttype_helper(x):
"Purchased",
"Profile",
"Labels",
"Labels+",
"Labels*",
]
)
if isinstance(x, str):
words = re.split(",| ", x)
words = list(map(lambda x: re.sub("[^a-zA-Z-]", "", str.title(x)), words))
words = list(map(lambda x: re.sub("[^a-zA-Z-\*\+]", "", str.title(x)), words))
if (
len(list(filter(lambda y: y not in choices and y[1:] not in choices, words)))
> 0
Expand All @@ -63,11 +65,13 @@ def download_helper(x):
"Purchased",
"Profile",
"Labels",
"Labels+",
"Labels*",
]
)
if isinstance(x, str):
words = re.split(",| ", x)
words = list(map(lambda x: re.sub("[^a-zA-Z-]", "", str.title(x)), words))
words = list(map(lambda x: re.sub("[^a-zA-Z\*\+]", "", str.title(x)), words))
if (
len(list(filter(lambda y: y not in choices and y[1:] not in choices), words))
> 0
Expand Down
12 changes: 6 additions & 6 deletions ofscraper/utils/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ def check_auth():


def check_config():
while not check.mp4decryptchecker(data.get_mp4decrypt()):
while not check.mp4decryptchecker(settings.get_mp4decrypt()):
console.get_shared_console().print(
"There is an issue with the mp4decrypt path\n\n"
)
log.debug(f"[bold]current mp4decrypt path[/bold] {data.get_mp4decrypt()}")
log.debug(f"[bold]current mp4decrypt path[/bold] {settings.get_mp4decrypt()}")
config_.update_mp4decrypt()
while not check.ffmpegchecker(data.get_ffmpeg()):
while not check.ffmpegchecker(settings.get_ffmpeg()):
console.get_shared_console().print("There is an issue with the ffmpeg path\n\n")
log.debug(f"[bold]current ffmpeg path[/bold] {data.get_ffmpeg()}")
log.debug(f"[bold]current ffmpeg path[/bold] {settings.get_ffmpeg()}")
config_.update_ffmpeg()
log.debug(f"[bold]final mp4decrypt path[/bold] {data.get_mp4decrypt()}")
log.debug(f"[bold]final ffmpeg path[/bold] {data.get_ffmpeg()}")
log.debug(f"[bold]final mp4decrypt path[/bold] {settings.get_mp4decrypt()}")
log.debug(f"[bold]final ffmpeg path[/bold] {settings.get_ffmpeg()}")


def check_config_key_mode():
Expand Down
18 changes: 18 additions & 0 deletions ofscraper/utils/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import shutil

import ofscraper.utils.args.read as read_args
import ofscraper.utils.config.data as config_data
import ofscraper.utils.constants as constants
Expand Down Expand Up @@ -120,3 +122,19 @@ def get_log_level():
if read_args.retriveArgs().log:
return read_args.retriveArgs().log
return constants.getattr("DEFAULT_LOG_LEVEL")


def get_mp4decrypt():
return (
config_data.get_mp4decrypt()
or shutil.which(constants.getattr("MP4_DECRYPT"))
or ""
)


def get_ffmpeg():
return (
config_data.get_ffmpeg()
or shutil.which(constants.getattr("FFMPEG_DECRYPT"))
or ""
)

0 comments on commit f03a5f6

Please sign in to comment.