Media Downloader - User Guide
============================

1. System requirements
   - Windows 10 or 11.
   - Google Chrome.
   - A working internet connection.
   - No Python installation is required. The package already contains a portable Python 3.11 runtime.

2. Install the extension (one time)
   - Open Chrome and go to chrome://extensions/.
   - Turn on "Developer mode" in the top right.
   - Click "Load unpacked".
   - Select the "extension" folder inside this directory.

3. Set up auto-start (one time, recommended)
   - Double-click "安装开机自启.bat".
   - This will:
       a) Register the service to start automatically every time you log in to Windows.
       b) Start the service right now (no black window, runs silently in background).
   - After this, you NEVER need to double-click anything else to start the service.
   - The extension will always be able to connect to it.

4. Download a video
   - Sign in to the platform you want to download from in Chrome (for example Douyin, Bilibili, YouTube).
   - Copy the video page link or share text.
   - Click the Media Downloader icon in the Chrome toolbar.
   - Paste the link into the input box and click Download.
   - Files are saved to Desktop\MediaDownloads by default.
   - When the green "Saved to" toast appears, click it to open the destination folder.

5. If the service is offline (rare)
   - Double-click "YOUTUBE下载器.bat". A black window will briefly flash and disappear.
     The service will start silently in the background.
   - This usually happens if the computer was rebooted and auto-start was disabled,
     or if an antivirus killed the service.

6. Douyin notes
   - Douyin share links can be pasted directly.
   - The tool reads the cookies from the Chrome Douyin login session, then resolves the real video URL locally.
   - If you see a cookie or login error, open https://www.douyin.com/ in Chrome, play any video for a few seconds, then try again.
   - If the download is slow, that is the network speed between your ISP and the Douyin CDN. The tool already uses chunked download and extra retries.

7. To remove the auto-start
   - Double-click "卸载开机自启.bat".
   - This removes the Windows startup registration and stops the running service.
   - You can still start the service manually anytime by double-clicking "YOUTUBE下载器.bat".

8. Common questions
   - "Local service offline" in the extension: run "YOUTUBE下载器.bat" once.
   - The extension icon is missing: open chrome://extensions/ and pin the extension to the toolbar.
   - A platform returns a download error: confirm that you are signed in to that platform in Chrome and that the video plays normally.
   - DRM-protected, member-only, region-restricted, or author-blocked content may not be downloadable.

9. Changes in v1.0.2
   - The "YOUTUBE下载器.bat" no longer shows a black window. It starts the service silently and exits immediately.
   - Added "安装开机自启.bat": double-click once to register the service to Windows startup. After that, the service starts automatically on every login, the extension always works, no more double-clicking needed.
   - Added "卸载开机自启.bat" for clean removal.
