domain_updater.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/usr/bin/env python3
  2. """domain_updater.py
  3. Facade entry point for vmess-domain-rotator.
  4. Delegates implementation to the modular rotator package while maintaining 100% backward compatibility
  5. for command line arguments and external python callers.
  6. """
  7. import sys
  8. import os
  9. # 确保可以直接导入同目录下的 rotator 包
  10. SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
  11. if SCRIPT_DIR not in sys.path:
  12. sys.path.insert(0, SCRIPT_DIR)
  13. from rotator.config import (
  14. build_output_settings,
  15. build_url,
  16. get_source_type,
  17. parse_timezone,
  18. print_output_settings,
  19. resolve_path,
  20. to_float_or_none,
  21. validate_config,
  22. )
  23. from rotator.filter import (
  24. DOMAIN_RE,
  25. IPV4_RE,
  26. apply_filter,
  27. collect_excluded_domains,
  28. flatten_values,
  29. get_by_json_path,
  30. get_values_by_path,
  31. normalize_domain,
  32. resolve_field,
  33. rule_matches,
  34. )
  35. from rotator.main import main, run_updater
  36. from rotator.notify import run_notify
  37. from rotator.scoring import (
  38. base_top_candidate,
  39. build_api_candidate,
  40. build_cfst_candidate,
  41. build_lexicographic_descriptors,
  42. build_top_candidates,
  43. choose_domain,
  44. choose_top_candidate_domains,
  45. cmp_scalar,
  46. get_sort_field_value,
  47. maybe_resolve_field,
  48. parse_created_time,
  49. parse_scored_records,
  50. rank_scored_records,
  51. set_if_nonempty_text,
  52. text_or_blank,
  53. )
  54. from rotator.sources import (
  55. extract_records,
  56. fetch_api_json,
  57. load_cfst_rows,
  58. parse_domains,
  59. )
  60. from rotator.storage import (
  61. _atomic_write,
  62. read_json_file,
  63. utc_now_iso,
  64. write_json_file,
  65. write_text_file,
  66. )
  67. __all__ = [
  68. "DOMAIN_RE",
  69. "IPV4_RE",
  70. "_atomic_write",
  71. "apply_filter",
  72. "base_top_candidate",
  73. "build_api_candidate",
  74. "build_cfst_candidate",
  75. "build_lexicographic_descriptors",
  76. "build_output_settings",
  77. "build_top_candidates",
  78. "build_url",
  79. "choose_domain",
  80. "choose_top_candidate_domains",
  81. "cmp_scalar",
  82. "collect_excluded_domains",
  83. "extract_records",
  84. "fetch_api_json",
  85. "flatten_values",
  86. "get_by_json_path",
  87. "get_sort_field_value",
  88. "get_source_type",
  89. "get_values_by_path",
  90. "load_cfst_rows",
  91. "main",
  92. "maybe_resolve_field",
  93. "normalize_domain",
  94. "parse_created_time",
  95. "parse_domains",
  96. "parse_scored_records",
  97. "parse_timezone",
  98. "print_output_settings",
  99. "rank_scored_records",
  100. "read_json_file",
  101. "resolve_field",
  102. "resolve_path",
  103. "rule_matches",
  104. "run_notify",
  105. "run_updater",
  106. "set_if_nonempty_text",
  107. "text_or_blank",
  108. "to_float_or_none",
  109. "utc_now_iso",
  110. "validate_config",
  111. "write_json_file",
  112. "write_text_file",
  113. ]
  114. if __name__ == "__main__":
  115. main()