pyproject.toml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. [build-system]
  2. requires = ["hatchling"]
  3. build-backend = "hatchling.build"
  4. [project]
  5. name = "yt-dlp"
  6. maintainers = [
  7. {name = "pukkandan", email = "pukkandan.ytdlp@gmail.com"},
  8. {name = "Grub4K", email = "contact@grub4k.xyz"},
  9. {name = "bashonly", email = "bashonly@protonmail.com"},
  10. {name = "coletdjnz", email = "coletdjnz@protonmail.com"},
  11. ]
  12. description = "A feature-rich command-line audio/video downloader"
  13. readme = "README.md"
  14. requires-python = ">=3.8"
  15. keywords = [
  16. "youtube-dl",
  17. "video-downloader",
  18. "youtube-downloader",
  19. "sponsorblock",
  20. "youtube-dlc",
  21. "yt-dlp",
  22. ]
  23. license = {file = "LICENSE"}
  24. classifiers = [
  25. "Topic :: Multimedia :: Video",
  26. "Development Status :: 5 - Production/Stable",
  27. "Environment :: Console",
  28. "Programming Language :: Python",
  29. "Programming Language :: Python :: 3 :: Only",
  30. "Programming Language :: Python :: 3.8",
  31. "Programming Language :: Python :: 3.9",
  32. "Programming Language :: Python :: 3.10",
  33. "Programming Language :: Python :: 3.11",
  34. "Programming Language :: Python :: 3.12",
  35. "Programming Language :: Python :: Implementation",
  36. "Programming Language :: Python :: Implementation :: CPython",
  37. "Programming Language :: Python :: Implementation :: PyPy",
  38. "License :: OSI Approved :: The Unlicense (Unlicense)",
  39. "Operating System :: OS Independent",
  40. ]
  41. dynamic = ["version"]
  42. dependencies = [
  43. "brotli; implementation_name=='cpython'",
  44. "brotlicffi; implementation_name!='cpython'",
  45. "certifi",
  46. "mutagen",
  47. "pycryptodomex",
  48. "requests>=2.32.2,<3",
  49. "urllib3>=1.26.17,<3",
  50. "websockets>=12.0",
  51. ]
  52. [project.optional-dependencies]
  53. default = []
  54. curl-cffi = [
  55. "curl-cffi>=0.5.10,!=0.6.*,<0.8; implementation_name=='cpython'",
  56. ]
  57. secretstorage = [
  58. "cffi",
  59. "secretstorage",
  60. ]
  61. build = [
  62. "build",
  63. "hatchling",
  64. "pip",
  65. "setuptools",
  66. "wheel",
  67. ]
  68. dev = [
  69. "pre-commit",
  70. "yt-dlp[static-analysis]",
  71. "yt-dlp[test]",
  72. ]
  73. static-analysis = [
  74. "autopep8~=2.0",
  75. "ruff~=0.5.0",
  76. ]
  77. test = [
  78. "pytest~=8.1",
  79. ]
  80. pyinstaller = [
  81. "pyinstaller>=6.7.0", # for compat with setuptools>=70
  82. ]
  83. py2exe = [
  84. "py2exe>=0.12",
  85. ]
  86. [project.urls]
  87. Documentation = "https://github.com/yt-dlp/yt-dlp#readme"
  88. Repository = "https://github.com/yt-dlp/yt-dlp"
  89. Tracker = "https://github.com/yt-dlp/yt-dlp/issues"
  90. Funding = "https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators"
  91. [project.scripts]
  92. yt-dlp = "yt_dlp:main"
  93. [project.entry-points.pyinstaller40]
  94. hook-dirs = "yt_dlp.__pyinstaller:get_hook_dirs"
  95. [tool.hatch.build.targets.sdist]
  96. include = [
  97. "/yt_dlp",
  98. "/devscripts",
  99. "/test",
  100. "/.gitignore", # included by default, needed for auto-excludes
  101. "/Changelog.md",
  102. "/LICENSE", # included as license
  103. "/pyproject.toml", # included by default
  104. "/README.md", # included as readme
  105. "/setup.cfg",
  106. "/supportedsites.md",
  107. ]
  108. artifacts = [
  109. "/yt_dlp/extractor/lazy_extractors.py",
  110. "/completions",
  111. "/AUTHORS", # included by default
  112. "/README.txt",
  113. "/yt-dlp.1",
  114. ]
  115. [tool.hatch.build.targets.wheel]
  116. packages = ["yt_dlp"]
  117. artifacts = ["/yt_dlp/extractor/lazy_extractors.py"]
  118. [tool.hatch.build.targets.wheel.shared-data]
  119. "completions/bash/yt-dlp" = "share/bash-completion/completions/yt-dlp"
  120. "completions/zsh/_yt-dlp" = "share/zsh/site-functions/_yt-dlp"
  121. "completions/fish/yt-dlp.fish" = "share/fish/vendor_completions.d/yt-dlp.fish"
  122. "README.txt" = "share/doc/yt_dlp/README.txt"
  123. "yt-dlp.1" = "share/man/man1/yt-dlp.1"
  124. [tool.hatch.version]
  125. path = "yt_dlp/version.py"
  126. pattern = "_pkg_version = '(?P<version>[^']+)'"
  127. [tool.hatch.envs.default]
  128. features = ["curl-cffi", "default"]
  129. dependencies = ["pre-commit"]
  130. path = ".venv"
  131. installer = "uv"
  132. [tool.hatch.envs.default.scripts]
  133. setup = "pre-commit install --config .pre-commit-hatch.yaml"
  134. yt-dlp = "python -Werror -Xdev -m yt_dlp {args}"
  135. [tool.hatch.envs.hatch-static-analysis]
  136. detached = true
  137. features = ["static-analysis"]
  138. dependencies = [] # override hatch ruff version
  139. config-path = "pyproject.toml"
  140. [tool.hatch.envs.hatch-static-analysis.scripts]
  141. format-check = "autopep8 --diff {args:.}"
  142. format-fix = "autopep8 --in-place {args:.}"
  143. lint-check = "ruff check {args:.}"
  144. lint-fix = "ruff check --fix {args:.}"
  145. [tool.hatch.envs.hatch-test]
  146. features = ["test"]
  147. dependencies = [
  148. "pytest-randomly~=3.15",
  149. "pytest-rerunfailures~=14.0",
  150. "pytest-xdist[psutil]~=3.5",
  151. ]
  152. [tool.hatch.envs.hatch-test.scripts]
  153. run = "python -m devscripts.run_tests {args}"
  154. run-cov = "echo Code coverage not implemented && exit 1"
  155. [[tool.hatch.envs.hatch-test.matrix]]
  156. python = [
  157. "3.8",
  158. "3.9",
  159. "3.10",
  160. "3.11",
  161. "3.12",
  162. "pypy3.8",
  163. "pypy3.9",
  164. "pypy3.10",
  165. ]
  166. [tool.ruff]
  167. line-length = 120
  168. [tool.ruff.lint]
  169. ignore = [
  170. "E402", # module-import-not-at-top-of-file
  171. "E501", # line-too-long
  172. "E731", # lambda-assignment
  173. "E741", # ambiguous-variable-name
  174. "UP036", # outdated-version-block
  175. "B006", # mutable-argument-default
  176. "B008", # function-call-in-default-argument
  177. "B011", # assert-false
  178. "B017", # assert-raises-exception
  179. "B023", # function-uses-loop-variable (false positives)
  180. "B028", # no-explicit-stacklevel
  181. "B904", # raise-without-from-inside-except
  182. "C401", # unnecessary-generator-set
  183. "C402", # unnecessary-generator-dict
  184. "PIE790", # unnecessary-placeholder
  185. "SIM102", # collapsible-if
  186. "SIM108", # if-else-block-instead-of-if-exp
  187. "SIM112", # uncapitalized-environment-variables
  188. "SIM113", # enumerate-for-loop
  189. "SIM114", # if-with-same-arms
  190. "SIM115", # open-file-with-context-handler
  191. "SIM117", # multiple-with-statements
  192. "SIM223", # expr-and-false
  193. "SIM300", # yoda-conditions
  194. "TD001", # invalid-todo-tag
  195. "TD002", # missing-todo-author
  196. "TD003", # missing-todo-link
  197. "PLE0604", # invalid-all-object (false positives)
  198. "PLE0643", # potential-index-error (false positives)
  199. "PLW0603", # global-statement
  200. "PLW1510", # subprocess-run-without-check
  201. "PLW2901", # redefined-loop-name
  202. "RUF001", # ambiguous-unicode-character-string
  203. "RUF012", # mutable-class-default
  204. "RUF100", # unused-noqa (flake8 has slightly different behavior)
  205. ]
  206. select = [
  207. "E", # pycodestyle Error
  208. "W", # pycodestyle Warning
  209. "F", # Pyflakes
  210. "I", # isort
  211. "Q", # flake8-quotes
  212. "N803", # invalid-argument-name
  213. "N804", # invalid-first-argument-name-for-class-method
  214. "UP", # pyupgrade
  215. "B", # flake8-bugbear
  216. "A", # flake8-builtins
  217. "COM", # flake8-commas
  218. "C4", # flake8-comprehensions
  219. "FA", # flake8-future-annotations
  220. "ISC", # flake8-implicit-str-concat
  221. "ICN003", # banned-import-from
  222. "PIE", # flake8-pie
  223. "T20", # flake8-print
  224. "RSE", # flake8-raise
  225. "RET504", # unnecessary-assign
  226. "SIM", # flake8-simplify
  227. "TID251", # banned-api
  228. "TD", # flake8-todos
  229. "PLC", # Pylint Convention
  230. "PLE", # Pylint Error
  231. "PLW", # Pylint Warning
  232. "RUF", # Ruff-specific rules
  233. ]
  234. [tool.ruff.lint.per-file-ignores]
  235. "devscripts/lazy_load_template.py" = [
  236. "F401", # unused-import
  237. ]
  238. "!yt_dlp/extractor/**.py" = [
  239. "I", # isort
  240. "ICN003", # banned-import-from
  241. "T20", # flake8-print
  242. "A002", # builtin-argument-shadowing
  243. "C408", # unnecessary-collection-call
  244. ]
  245. "yt_dlp/jsinterp.py" = [
  246. "UP031", # printf-string-formatting
  247. ]
  248. [tool.ruff.lint.isort]
  249. known-first-party = [
  250. "bundle",
  251. "devscripts",
  252. "test",
  253. ]
  254. relative-imports-order = "closest-to-furthest"
  255. [tool.ruff.lint.flake8-quotes]
  256. docstring-quotes = "double"
  257. multiline-quotes = "single"
  258. inline-quotes = "single"
  259. avoid-escape = false
  260. [tool.ruff.lint.pep8-naming]
  261. classmethod-decorators = [
  262. "yt_dlp.utils.classproperty",
  263. ]
  264. [tool.ruff.lint.flake8-import-conventions]
  265. banned-from = [
  266. "base64",
  267. "datetime",
  268. "functools",
  269. "glob",
  270. "hashlib",
  271. "itertools",
  272. "json",
  273. "math",
  274. "os",
  275. "pathlib",
  276. "random",
  277. "re",
  278. "string",
  279. "sys",
  280. "time",
  281. "urllib.parse",
  282. "uuid",
  283. "xml",
  284. ]
  285. [tool.ruff.lint.flake8-tidy-imports.banned-api]
  286. "yt_dlp.compat.compat_str".msg = "Use `str` instead."
  287. "yt_dlp.compat.compat_b64decode".msg = "Use `base64.b64decode` instead."
  288. "yt_dlp.compat.compat_urlparse".msg = "Use `urllib.parse` instead."
  289. "yt_dlp.compat.compat_parse_qs".msg = "Use `urllib.parse.parse_qs` instead."
  290. "yt_dlp.compat.compat_urllib_parse_unquote".msg = "Use `urllib.parse.unquote` instead."
  291. "yt_dlp.compat.compat_urllib_parse_urlencode".msg = "Use `urllib.parse.urlencode` instead."
  292. "yt_dlp.compat.compat_urllib_parse_urlparse".msg = "Use `urllib.parse.urlparse` instead."
  293. "yt_dlp.compat.compat_shlex_quote".msg = "Use `yt_dlp.utils.shell_quote` instead."
  294. "yt_dlp.utils.error_to_compat_str".msg = "Use `str` instead."
  295. [tool.autopep8]
  296. max_line_length = 120
  297. recursive = true
  298. exit-code = true
  299. jobs = 0
  300. select = [
  301. "E101",
  302. "E112",
  303. "E113",
  304. "E115",
  305. "E116",
  306. "E117",
  307. "E121",
  308. "E122",
  309. "E123",
  310. "E124",
  311. "E125",
  312. "E126",
  313. "E127",
  314. "E128",
  315. "E129",
  316. "E131",
  317. "E201",
  318. "E202",
  319. "E203",
  320. "E211",
  321. "E221",
  322. "E222",
  323. "E223",
  324. "E224",
  325. "E225",
  326. "E226",
  327. "E227",
  328. "E228",
  329. "E231",
  330. "E241",
  331. "E242",
  332. "E251",
  333. "E252",
  334. "E261",
  335. "E262",
  336. "E265",
  337. "E266",
  338. "E271",
  339. "E272",
  340. "E273",
  341. "E274",
  342. "E275",
  343. "E301",
  344. "E302",
  345. "E303",
  346. "E304",
  347. "E305",
  348. "E306",
  349. "E502",
  350. "E701",
  351. "E702",
  352. "E704",
  353. "W391",
  354. "W504",
  355. ]
  356. [tool.pytest.ini_options]
  357. addopts = "-ra -v --strict-markers"
  358. markers = [
  359. "download",
  360. ]