NanmiCoder/MediaCrawler · error · ValueError
[DouyinStoreFactory.create_store] Invalid save option only s
Error message
[DouyinStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...
What it means
Raised by DouyinStoreFactory.create_store() when config.SAVE_DATA_OPTION is not a key of the douyin STORES registry (csv, db, postgres, json, jsonl, sqlite, mongodb, excel). Fail-fast guard at store creation time — the douyin crawler refuses to run with an unregistered persistence backend.
Source
Thrown at store/douyin/__init__.py:50
class DouyinStoreFactory:
STORES = {
"csv": DouyinCsvStoreImplement,
"db": DouyinDbStoreImplement,
"postgres": DouyinDbStoreImplement,
"json": DouyinJsonStoreImplement,
"jsonl": DouyinJsonlStoreImplement,
"sqlite": DouyinSqliteStoreImplement,
"mongodb": DouyinMongoStoreImplement,
"excel": DouyinExcelStoreImplement,
}
@staticmethod
def create_store() -> AbstractStore:
store_class = DouyinStoreFactory.STORES.get(config.SAVE_DATA_OPTION)
if not store_class:
raise ValueError("[DouyinStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...")
return store_class()
def _extract_note_image_list(aweme_detail: Dict) -> List[str]:
"""
Extract note image list
Args:
aweme_detail (Dict): Douyin content details
Returns:
List[str]: Note image list
"""
images_res: List[str] = []
images: List[Dict] = aweme_detail.get("images", [])
if not images:
return []View on GitHub (pinned to d6f7c5bb90)
Solutions
- Use one of: csv, db, postgres, json, jsonl, sqlite, mongodb, excel — exactly lowercase
- Prefer 'sqlite' for a zero-dependency local run; 'db' only if MySQL connection env vars are set
- Verify the effective value: python -c 'import config; print(config.SAVE_DATA_OPTION)'
- Register a custom store class in DouyinStoreFactory.STORES if you need an extra backend
Example fix
// before SAVE_DATA_OPTION = "xlsx" // after SAVE_DATA_OPTION = "excel"
Defensive patterns
Strategy: validation
Validate before calling
from store.douyin import DouyinStoreFactory
if config.SAVE_DATA_OPTION not in DouyinStoreFactory.STORES:
raise SystemExit(
f"SAVE_DATA_OPTION={config.SAVE_DATA_OPTION!r} invalid; "
f"choose from {sorted(DouyinStoreFactory.STORES)}"
) Type guard
def is_valid_save_option(opt: str) -> bool:
return isinstance(opt, str) and opt in DouyinStoreFactory.STORES Try / catch
try:
store = DouyinStoreFactory.create_store()
except ValueError as e:
raise SystemExit(f"fix config before crawling: {e}") from e Prevention
- SAVE_DATA_OPTION is shared across platforms — set it once, correctly
- 'db' means MySQL; there is no 'mysql' key
- Print repr() of the option to catch whitespace/case issues
When it happens
Trigger: SAVE_DATA_OPTION set to 'mysql' (the MySQL impl is registered under 'db'), 'xlsx' instead of 'excel', or any value not in the registry; triggered on first store access during a douyin crawl.
Common situations: Users migrating configs from other crawlers that use different option names; switching storage mid-project and misspelling the option; env var SAVE_DATA_OPTION overriding the intended base_config value.
Related errors
- [BiliStoreFactory.create_store] Invalid save option only sup
- [KuaishouStoreFactory.create_store] Invalid save option only
- [TieBaStoreFactory.create_store] Invalid save option only su
- [WeibotoreFactory.create_store] Invalid save option only sup
- [XhsStoreFactory.create_store] Invalid save option only supp
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/a2d615fa53e78dc3.
Report an issue: GitHub.