Skip to content

feat: Add automatic poster download and upload feature#56

Open
Doublefire-Chen wants to merge 77 commits into
bjdbjd:mainfrom
Doublefire-Chen:main
Open

feat: Add automatic poster download and upload feature#56
Doublefire-Chen wants to merge 77 commits into
bjdbjd:mainfrom
Doublefire-Chen:main

Conversation

@Doublefire-Chen

Copy link
Copy Markdown
  • Created new poster.py module for downloading and uploading posters
  • Added browser headers to bypass Douban anti-spider protection
  • Updated settings UI with new checkbox for poster feature
  • Feature works in both manual (获取 button) and automated (一键启动) workflows
  • Enhanced PT-Gen API to return both format text and full response data
  • Fixed macOS locale issue with QDoubleSpinBox (comma vs dot in decimals)

- Created new poster.py module for downloading and uploading posters
- Added browser headers to bypass Douban anti-spider protection
- Updated settings UI with new checkbox for poster feature
- Feature works in both manual (获取 button) and automated (一键启动) workflows
- Enhanced PT-Gen API to return both format text and full response data
- Fixed macOS locale issue with QDoubleSpinBox (comma vs dot in decimals)
- Updated all three upload result handlers (movie/tv/playlet) to accept 5 parameters matching UploadPictureThread signal
- Fixed exception handler in UploadPictureThread to emit all required parameters
- Added null check for API response data in lsky_pro_picture_bed
- Improved error messages to show actual response text for better debugging
- Only delete temp file on successful upload for debugging failed uploads
- Print downloaded file size after download completes
- Print file path and size info when upload fails
- Print request URL, headers, file path and size before upload
- Print response headers after upload
- Handle empty response text in output
- Add ToastNotification widget with fade animations
- Support error/warning/info/success notification types
- Auto-dismiss after configurable duration
- Show toast when rename fails during one-click start
- Add support for both ◎ and ❁ prefix formats
- Add fallback patterns for year extraction
- Add debug logging for troubleshooting
- Change pattern to stop at prefix characters (◎❁)
- Use [^◎❁\n]+ instead of (.*?) for title capture
- Add more debug logging for troubleshooting
- Clean up duplicate code
- Create main_cli.py with interactive prompts
- Support content type selection (movie/TV/playlet)
- Colored terminal output with progress indicators
- Movie workflow: PT-Gen, video info, MediaInfo, rename, screenshot, torrent
- Extract description string from (text, dict) tuple
- Strip quotes from path input for Windows
- Add auto-upload screenshot functionality with progress display
- Implement thumbnail generation support
- Add screenshot deletion after upload
- Implement make_dir and create_hard_link features
- Use all screenshot settings (threshold, percentages, etc)
- Add settings summary display at startup
- Improve source/team selection with combo-box data
- Better cross-platform path handling
- Enhance user experience with detailed feedback

Now CLI mode behaves consistently with GUI mode
- Automatically retry with backup API when primary fails
- Show clear warning/success messages for each attempt
- Consistent with GUI fallback behavior
- Only fail if both primary and backup APIs fail
- Prevent duplicate attempts to same URL
- Add '# isort: skip_file' to prevent auto-reordering
- Move stdlib imports (os, sys, time) before local imports
- Fixes UnboundLocalError: 'cannot access local variable os'
- Add explanatory comment about critical import order
- Error occurred in rename operations using os.path.dirname()
- isort pre-commit hook was reverting the fix automatically
- Rename both folder AND file (not just one or the other)
- Convert short paths like '情圣3L~1.MKV' to full long names
- Use Windows GetLongPathNameW API via ctypes
- Display expanded path for user verification
- Add helpful error message for unresolved short paths
- Fixes path not found errors with Windows short names
- Use built-in os.path.realpath() which handles 8.3 format automatically
- No external packages or ctypes needed (cleaner, more maintainable)
- Cross-platform solution works on Windows, Linux, macOS
- Resolves symbolic links as bonus feature
- Simpler error handling with fallback to normpath()
- Better debugging messages for invalid path segments
- Check if original short path exists before attempting expansion
- Only expand paths when original doesn't exist (avoid breaking valid short paths)
- Use expanded path only if it actually exists
- Show both original and expanded paths in error message if both fail
- Fixes issue where realpath() incorrectly expands valid short paths
Add custom Tab key binding that applies completion and triggers new completion cycle if the result is a directory path (ends with separator).
- Add custom Tab key binding to refresh completions after completing a directory path
- Use select_first=True to highlight first completion automatically
Add project root to sys.path before imports so absolute imports like 'from src.core...' work when running the script directly.
Users can now enter 0, q, or Q to exit the program from the main menu.
Add getch() function for cross-platform single character input.
Menu now responds immediately when user presses 0-3 or q.
Append uploaded picture BBCode URLs to description in CLI mode, matching GUI behavior. Controlled by paste_screenshot_url setting.
Applied to movie, TV, and playlet workflows.
- Add process_poster_in_description() to download and re-upload poster, replacing the original URL in description (matches GUI behavior)
- Fix screenshot order: screenshots first, thumbnail at end (was reversed)
- Controlled by auto_download_upload_poster setting
- Applied to movie, TV, and playlet workflows
- Use {集数} placeholder in file_name template
- Replace {集数} with padded episode number for each file
- Iterate through all video files in folder with proper episode numbers
- Remove episode placeholder from folder name
- Pad episode numbers to at least 2 digits (01, 02, etc.)
- Fixes missing episode number (S01E instead of S01E01)
- Fixes double .mkv extension issue
- Import and call delete_season_number() like GUI does
- Removes 'Season 1' etc. from english_title before generating filename
- Add debug output for title tracing
- Restore original regex pattern with literal full-width spaces for ◎ prefix
- Restore crucial reordering logic: matches.insert(0, matches.pop())
- Keep fallback for ❁ prefix format (alternative PT-Gen APIs)
- Remove debug output from main_cli.py
The previous changes broke Chinese title extraction because:
1. \s* doesn't match full-width spaces ( ) in Python regex
2. Removing reordering caused 译名 to be processed before 片名
- Add fallback patterns for year, categories, episodes with ❁ prefix
- Only reorder matches for ◎ format (❁ format already has 片名 first)
- Add fallback actor pattern for ❁ prefix format
- Update language check to handle ❁ format in categories
 The ◎ and ❁ formats have different field orders:
- ◎ format: 译名 before 片名 (needs reordering)
- ❁ format: 片名 before 译名 (no reordering needed)
Linux users need to manually install libmediainfo for pymediainfo.
Windows and macOS users don't need manual installation as pymediainfo wheels bundle the required library.
Change except ImportError to except Exception to catch PyperclipException when running on headless Linux systems without a clipboard mechanism.
The code gracefully falls back to platform-specific methods or saves the link to a file.
- Add raw_data parameter to get_pt_gen_info() for direct JSON extraction
- Each field independently falls back to regex when raw data is missing
- Extend GetPtGenThread signal to pass raw API response through GUI
- Simplify CLI by removing post-hoc fallback blocks
- Fix pre-existing return value unpack bugs in startapi.py (6/7 → 8)
- Add comparison section to debug_ptgen.py
- Add 18 unit tests in tests/test_rename_info.py
- Insert chinese_title as 译名 (translated name) line
- Move original aka titles to new 别名 (alias) line
- Handles both ◎ and ❁ prefix formats
The previous implementation called str.replace(' '+season_number, '')
unconditionally, which also stripped the digit when it appeared inside
a year embedded in the title. For example, with season_number='1' the
pinyin-derived english_title 'Ni Hao 1983' became 'Ni Hao983', and the
final TV file name became 你好1983.Ni.Hao983.S01E01.2026- instead of
你好1983.Ni.Hao.1983.S01E01.2026-.

Match suffixes only at the end of the title (after rstrip), and try
the longest suffix first so " Season 1" is not pre-empted by " 1".
The debug script was passing season_str='S01' and episode='E01' to
get_name_from_template, but the templates already contain the literal
'S{season}E{episode}' — so substitution produced 'SS01EE01', collapsed
by a local clean_name helper into misleading output like 'SEE01'.

Pass season='01' (no 'S' prefix) and episode='01' (no 'E' prefix) the
same way src/api/startapi.py and src/main_cli.py do, drop the local
clean_name wrapper (get_name_from_template already handles file_name
cleanup), and default season to 1 when PT-Gen does not return one
(matching the CLI default and the GUI's season input default).
When a file is dragged into a terminal on macOS/Linux the shell
inserts backslash escapes (\, \ \(). prompt_toolkit reads those
literally, so the resulting string does not match the file on disk.
Fall back to shlex unescaping when the path does not exist and
contains backslashes.
When the file is already inside the target folder, the post-condition
(file lives in folder X) holds, so the move is a no-op rather than a
failure. Previously every caller (CLI, GUI, API) bailed out on the
False return and aborted the rename pipeline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant