← yt-playlist-export

pip installation (#1)

dccd75c7f6b3b2b074ef52e39b46bf8bf9b2243e · Aleksandr Tabakov · Aug 5, 2024 16:47

Co-authored-by: Aleksandr Tabakov <alex.daymon+gitlab@gmail.com>

+93 −15 · 7 files changed

  • .gitignore +3 −0
  • LICENSE +24 −0
  • README.md +4 −7
  • pyproject.toml +45 −0
  • src/yt_playlist_export/__init__.py +5 −0
  • src/yt_playlist_export/__main__.py +3 −0
  • yt-playlist-export.py => src/yt_playlist_export/yt_playlist_export.py +9 −8
diff --git a/.gitignore b/.gitignore
index 924cea8..868dca9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
 .etc
+__pycache__
+dist
+venv
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
diff --git a/README.md b/README.md
index 4e0e702..ccafb49 100644
--- a/README.md
+++ b/README.md
@@ -4,15 +4,13 @@ yt-playlist-export is a tool that allows to export YouTube playlists, export You
 
 ## Installation
 
-```bash
-git clone https://github.com/daydiff/yt-playlist-export.git
-cd yt-playlist-export
-python3 -m pip install -r requirements.txt
+```bash {"id":"01J4HFTRJ1CK76GD127E1R65GX"}
+python3 -m pip install yt-playlist-export
 ```
 
 ## Usage
 
-```bash
+```bash {"id":"01J4HFTRJ1CK76GD127F41SF28"}
 yt-playlist-export -h
 usage: yt-playlist-export [-h] [--browser BROWSER] [-f {csv,json}] [-o OUTPUT] [-v] playlist [playlist ...]
 
@@ -33,13 +31,12 @@ optional arguments:
 
 ## Show case
 
-```bash
+```bash {"id":"01J4HFTRJ1CK76GD127FGZF1W0"}
 yt-playlist-export https://www.youtube.com/playlist\?list\=PL0XfG7TzasxNCl8a-SdyvSoazX1VYBweF -f csv -o test.csv
 ```
 
 ![YouTube playlist exported to CSV](/assets/format_csv.png)
 
-
 ## Dependencies
 
 yt-playlist-export is using [yt-dlp](https://github.com/yt-dlp) under the hood.
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..ccabdc2
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,45 @@
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[project]
+name = "yt-playlist-export"
+version = "0.0.1"
+authors = [
+  { name="Aleksandr Tabakov", email="info@atabakoff.com" },
+]
+description = "yt-playlist-export is a tiny Python tool that allows to export private YouTube playlists, export YouTube's \"Watch later\" list and export YouTube \"Liked videos\""
+readme = "README.md"
+requires-python = ">=3.8"
+keywords = [
+    "youtube",
+    "youtube-playlist",
+    "youtube-playlist-backup",
+    "youtube-playlist-export ",
+]
+license = {file = "LICENSE"}
+classifiers = [
+    "Programming Language :: Python :: 3",
+    "License :: OSI Approved :: The Unlicense (Unlicense)",
+    "Operating System :: OS Independent",
+]
+dependencies = [
+    "yt-dlp"
+]
+
+[project.urls]
+Homepage = "https://github.com/daydiff/yt-playlist-export"
+Issues = "https://github.com/daydiff/yt-playlist-export/issues"
+
+[project.scripts]
+yt-playlist-export = "yt_playlist_export:main"
+
+
+[tool.hatch.build.targets.sdist]
+include = [
+    "/src",
+    "/.gitignore",  # included by default, needed for auto-excludes
+    "/LICENSE",  # included as license
+    "/pyproject.toml",  # included by default
+    "/README.md",  # included as readme
+]
diff --git a/src/yt_playlist_export/__init__.py b/src/yt_playlist_export/__init__.py
new file mode 100644
index 0000000..0e72146
--- /dev/null
+++ b/src/yt_playlist_export/__init__.py
@@ -0,0 +1,5 @@
+from .yt_playlist_export import main
+
+__all__ = [
+    "main"
+]
diff --git a/src/yt_playlist_export/__main__.py b/src/yt_playlist_export/__main__.py
new file mode 100644
index 0000000..493ccb5
--- /dev/null
+++ b/src/yt_playlist_export/__main__.py
@@ -0,0 +1,3 @@
+if __name__ == "__main__":
+    from yt_playlist_export import main
+    main()
diff --git a/yt-playlist-export.py b/src/yt_playlist_export/yt_playlist_export.py
similarity index 89%
rename from yt-playlist-export.py
rename to src/yt_playlist_export/yt_playlist_export.py
index 12451e7..a4c457d 100755
--- a/yt-playlist-export.py
+++ b/src/yt_playlist_export/yt_playlist_export.py
@@ -97,11 +97,12 @@ ydl_opts = {
     'quiet': not verbose
 }
 
-with yt_dlp.YoutubeDL(ydl_opts) as ydl:
-    info = ydl.extract_info(playlist, download=False)
-    # ydl.sanitize_info makes the info json-serializable
-    info_sanitized = ydl.sanitize_info(info)
-    if format == 'json':
-        print_json(info_sanitized)
-    else:
-        print_csv(info_sanitized)
+def main():
+    with yt_dlp.YoutubeDL(ydl_opts) as ydl:
+        info = ydl.extract_info(playlist, download=False)
+        # ydl.sanitize_info makes the info json-serializable
+        info_sanitized = ydl.sanitize_info(info)
+        if format == 'json':
+            print_json(info_sanitized)
+        else:
+            print_csv(info_sanitized)