Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

added an option "no-album-sorting" to remove the prefixes in albums #490

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ commands =
[tool.ruff]
src = ["src", "tests"]
line-length = 88

[tool.ruff.lint]
select = [
"C4", # flake8-comprehensions - https://beta.ruff.rs/docs/rules/#flake8-comprehensions-c4
"E", # pycodestyle errors - https://beta.ruff.rs/docs/rules/#error-e
Expand Down
7 changes: 6 additions & 1 deletion src/gphotos_sync/GoogleAlbumsSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(
self._ntfs_override = settings.ntfs_override
self.month_format = settings.month_format
self.path_format = settings.path_format
self._no_album_sorting = settings.no_album_sorting

@classmethod
def make_search_parameters(
Expand Down Expand Up @@ -309,7 +310,11 @@ def create_album_content_links(self):

link_folder: Path = self.album_folder_name(album_name, start_date, end_date)

link_filename = "{:04d}_{}".format(album_item, file_name)
if self._no_album_sorting:
link_filename = "{}".format(file_name)
else:
link_filename = "{:04d}_{}".format(album_item, file_name)

link_filename = link_filename[: get_check().max_filename]
link_file = link_folder / link_filename
# incredibly, pathlib.Path.relative_to cannot handle
Expand Down
1 change: 1 addition & 0 deletions src/gphotos_sync/Settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Settings:
album_index: bool
omit_album_date: bool
album_invert: bool
no_album_sorting: bool
album: str
album_regex: str
shared_albums: bool
Expand Down
6 changes: 6 additions & 0 deletions src/gphotos_sync/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def __init__(self):
help="Make the album date the same as its earliest "
"photo. The default is its last photo",
)
parser.add_argument(
"--no-album-sorting",
action="store_true",
help="Remove prefix in photo filename inside the album folders",
)
parser.add_argument(
"--start-date",
help="Set the earliest date of files to sync" "format YYYY-MM-DD",
Expand Down Expand Up @@ -380,6 +385,7 @@ def setup(self, args: Namespace, db_path: Path):
path_format=args.path_format,
image_timeout=args.image_timeout,
video_timeout=args.video_timeout,
no_album_sorting=args.no_album_sorting,
)

self.google_photos_client = RestClient(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_units/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ def test_fs_overrides(self):
)
s.gp.fs_checks(s.root, s.parsed_args)
self.assertTrue(get_check().is_linux)
self.assertEqual(get_check().max_filename, 255)
self.assertTrue(get_check().max_filename >= 242)
Loading