Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
1gintonic committed Jun 19, 2024
1 parent ec92738 commit 955c26d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 121 deletions.
4 changes: 2 additions & 2 deletions config/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from errors import ConfigError
from textio import print_debug, print_warning
from utils.common import is_valid_post_id, save_config_or_raise, get_post_id_from_request
from utils.common import is_valid_post_id, save_config_or_raise, get_post_ids_from_list_of_requests


def parse_args() -> argparse.Namespace:
Expand Down Expand Up @@ -376,7 +376,7 @@ def map_args_to_config(args: argparse.Namespace, config: FanslyConfig) -> None:
config_overridden = True

if args.download_mode_posts is not None:
post_ids = get_post_id_from_request(args.download_mode_single)
post_ids = get_post_ids_from_list_of_requests(args.download_mode_posts)
config.download_mode = DownloadMode.POSTS

for post_id in post_ids:
Expand Down
19 changes: 10 additions & 9 deletions download/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from config import FanslyConfig
from fileio.dedupe import dedupe_init
from textio import input_enter_continue, print_error, print_info, print_warning
from utils.common import is_valid_post_id
from utils.common import is_valid_post_id, get_post_id_from_request


def download_posts(config: FanslyConfig, state: DownloadState):
Expand All @@ -31,8 +31,8 @@ def download_posts(config: FanslyConfig, state: DownloadState):
)

else:
print_info(f"Please enter the IDs of the posts you would like to download one after another (confirm with <Enter>)."
f"\n{17*' '}After you click on a post, it will show in your browsers URL bar."
print_info(f"Please enter the links or the IDs of the posts you would like to download one after another (confirm with <Enter>)."
f"\n{17*' '}After you click on a post, the ID will show in your browser's URL bar."
)
print()

Expand All @@ -41,20 +41,21 @@ def download_posts(config: FanslyConfig, state: DownloadState):

while len(post_id) > 0:
while True:
post_id = input(f"\n{17*' '}► Post ID: ")
requested_post = input(f"\n{17 * ' '}► Post Link or ID: ")
post_id = get_post_id_from_request(requested_post)

if len(post_id) == 0:
print_info("All desired post IDs are recorded. Proceeding to download.")
print_info("All desired post links or IDs are recorded. Proceeding to download.")
break
elif is_valid_post_id(post_id):
post_ids.append(post_id)
print_info(f"Post {post_id} is recorded. Enter the next one or hit enter to proceed.")
break
else:
print_error(f"The input string '{post_id}' can not be a valid post ID."
print_error(f"The input string '{requested_post}' can not be a valid post link or ID."
f"\n{22*' '}The last few numbers in the url is the post ID"
f"\n{22*' '}Example: 'https://fansly.com/post/1283998432982'"
f"\n{22*' '}In the example, '1283998432982' would be the post ID.",
f"\n{22*' '}In the example, '1283998432982' is the post ID.",
17
)

Expand Down Expand Up @@ -93,9 +94,9 @@ def download_posts(config: FanslyConfig, state: DownloadState):
state.creator_name = creator_username

if creator_display_name and creator_username:
print_info(f"Inspecting a post by {creator_display_name} (@{creator_username})")
print_info(f"Inspecting post {post_id} by {creator_display_name} (@{creator_username})")
else:
print_info(f"Inspecting a post by {creator_username.capitalize()}")
print_info(f"Inspecting post {post_id} by {creator_username.capitalize()}")

# Deferred deduplication init because directory may have changed
# depending on post creator (!= configured creator)
Expand Down
110 changes: 0 additions & 110 deletions download/single.py

This file was deleted.

15 changes: 15 additions & 0 deletions utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ def get_post_id_from_request(requested_post: str) -> str:
return post_id


def get_post_ids_from_list_of_requests(requested_posts: list[str]) -> list[str]:
"""Strips post_ids from a list of post links if necessary.
:param requested_posts: The list of requests made by the user.
:type requested_posts: list[str]
:return: A list of extracted post_ids.
:rtype: list[str]
"""
post_ids = []
for requested_post in requested_posts:
post_ids.append(get_post_id_from_request(requested_post))
return post_ids


def open_location(filepath: Path, open_folder_when_finished: bool, interactive: bool) -> bool:
"""Opens the download directory in the platform's respective
file manager application once the download process has finished.
Expand Down

0 comments on commit 955c26d

Please sign in to comment.