py-youtube-search 0.2.0__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-youtube-search
3
+ Version: 0.2.2
4
+ Summary: A lightweight, regex-based YouTube search library without API keys.
5
+ Home-page: https://github.com/VishvaRam/py-youtube-search
6
+ Author: VishvaRam
7
+ Author-email: murthyvishva@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: aiohttp>=3.8.0
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # py-youtube-search
27
+
28
+ A lightweight, asynchronous Python library to search YouTube videos programmatically without an API key.
29
+ It scrapes search results using `aiohttp` and `re`, making it fast, robust, and perfect for high-performance applications.
30
+
31
+ ## Features
32
+
33
+ - **Async Support**: Fully asynchronous using `aiohttp` for non-blocking execution.
34
+ - **Reusable Client**: Create a single instance and run multiple searches with different configurations.
35
+ - **No API Key Required**: Search YouTube directly without setting up Google Cloud projects.
36
+ - **Advanced Filtering**: Built-in support for duration (Medium 3-20m, Long >20m) and upload date filters.
37
+ - **Rich Data Extraction**: Extracts Video ID, Title, Duration, and View Count using optimized regex.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install py-youtube-search
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ### 1. Basic Async Search
48
+ Initialize the client once and run multiple searches.
49
+
50
+ ```python
51
+ import asyncio
52
+ from py_youtube_search import YouTubeSearch
53
+
54
+ async def main():
55
+ # 1. Initialize the client (reusable)
56
+ yt = YouTubeSearch()
57
+
58
+ # 2. Run a search
59
+ videos = await yt.search("Python async tutorials", limit=5)
60
+
61
+ for v in videos:
62
+ print(f"Title: {v['title']}")
63
+ print(f"Duration: {v['duration']}")
64
+ print(f"Views: {v['views']}")
65
+ print(f"Link: https://www.youtube.com/watch?v={v['id']}\n")
66
+
67
+ if __name__ == "__main__":
68
+ asyncio.run(main())
69
+ ```
70
+
71
+ ### 2. Advanced Search with Filters
72
+ Search for specific content, like long-form videos (>20m) uploaded this week.
73
+
74
+ ```python
75
+ import asyncio
76
+ from py_youtube_search import YouTubeSearch, Filters
77
+
78
+ async def main():
79
+ yt = YouTubeSearch()
80
+
81
+ # Search 1: Long videos about LangGraph
82
+ print("Searching for LangGraph...")
83
+ videos = await yt.search("LangGraph", sp=Filters.long_this_week, limit=3)
84
+
85
+ for v in videos:
86
+ print(f"🎥 {v['title']} | ⏱ {v['duration']} | 👁 {v['views']}")
87
+
88
+ # Search 2: Reusing the same client for a different query
89
+ print("\nSearching for Python...")
90
+ videos_py = await yt.search("Python 3.12", sp=Filters.medium_today, limit=3)
91
+
92
+ for v in videos_py:
93
+ print(f"🐍 {v['title']}")
94
+
95
+ if __name__ == "__main__":
96
+ asyncio.run(main())
97
+ ```
98
+
99
+ ## Available Filters
100
+
101
+ Pass these constants into the `sp` parameter of the `search()` method.
102
+
103
+ ### Duration: Medium (3 - 20 Minutes)
104
+ | Filter Attribute | Description |
105
+ | :--- | :--- |
106
+ | `Filters.medium_today` | Uploaded **Today** |
107
+ | `Filters.medium_this_week` | Uploaded **This Week** |
108
+ | `Filters.medium_this_month` | Uploaded **This Month** |
109
+ | `Filters.medium_this_year` | Uploaded **This Year** |
110
+
111
+ ### Duration: Long (Over 20 Minutes)
112
+ | Filter Attribute | Description |
113
+ | :--- | :--- |
114
+ | `Filters.long_today` | Uploaded **Today** |
115
+ | `Filters.long_this_week` | Uploaded **This Week** |
116
+ | `Filters.long_this_month` | Uploaded **This Month** |
117
+ | `Filters.long_this_year` | Uploaded **This Year** |
118
+
119
+ ## Data Structure
120
+
121
+ The `.search()` method returns a list of dictionaries:
122
+
123
+ ```json
124
+ [
125
+ {
126
+ "id": "lDoYisPfcck",
127
+ "title": "Hack the planet! LangGraph AI HackBot Dev & Q/A",
128
+ "duration": "1:05:23",
129
+ "views": "1.2K views",
130
+ "url_suffix": "/watch?v=lDoYisPfcck"
131
+ }
132
+ ]
133
+ ```
134
+
135
+ ## Dependencies
136
+ - `aiohttp` (for async requests)
137
+
138
+ ## License
139
+ MIT License. See LICENSE file for details.
@@ -0,0 +1,114 @@
1
+ # py-youtube-search
2
+
3
+ A lightweight, asynchronous Python library to search YouTube videos programmatically without an API key.
4
+ It scrapes search results using `aiohttp` and `re`, making it fast, robust, and perfect for high-performance applications.
5
+
6
+ ## Features
7
+
8
+ - **Async Support**: Fully asynchronous using `aiohttp` for non-blocking execution.
9
+ - **Reusable Client**: Create a single instance and run multiple searches with different configurations.
10
+ - **No API Key Required**: Search YouTube directly without setting up Google Cloud projects.
11
+ - **Advanced Filtering**: Built-in support for duration (Medium 3-20m, Long >20m) and upload date filters.
12
+ - **Rich Data Extraction**: Extracts Video ID, Title, Duration, and View Count using optimized regex.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install py-youtube-search
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### 1. Basic Async Search
23
+ Initialize the client once and run multiple searches.
24
+
25
+ ```python
26
+ import asyncio
27
+ from py_youtube_search import YouTubeSearch
28
+
29
+ async def main():
30
+ # 1. Initialize the client (reusable)
31
+ yt = YouTubeSearch()
32
+
33
+ # 2. Run a search
34
+ videos = await yt.search("Python async tutorials", limit=5)
35
+
36
+ for v in videos:
37
+ print(f"Title: {v['title']}")
38
+ print(f"Duration: {v['duration']}")
39
+ print(f"Views: {v['views']}")
40
+ print(f"Link: https://www.youtube.com/watch?v={v['id']}\n")
41
+
42
+ if __name__ == "__main__":
43
+ asyncio.run(main())
44
+ ```
45
+
46
+ ### 2. Advanced Search with Filters
47
+ Search for specific content, like long-form videos (>20m) uploaded this week.
48
+
49
+ ```python
50
+ import asyncio
51
+ from py_youtube_search import YouTubeSearch, Filters
52
+
53
+ async def main():
54
+ yt = YouTubeSearch()
55
+
56
+ # Search 1: Long videos about LangGraph
57
+ print("Searching for LangGraph...")
58
+ videos = await yt.search("LangGraph", sp=Filters.long_this_week, limit=3)
59
+
60
+ for v in videos:
61
+ print(f"🎥 {v['title']} | ⏱ {v['duration']} | 👁 {v['views']}")
62
+
63
+ # Search 2: Reusing the same client for a different query
64
+ print("\nSearching for Python...")
65
+ videos_py = await yt.search("Python 3.12", sp=Filters.medium_today, limit=3)
66
+
67
+ for v in videos_py:
68
+ print(f"🐍 {v['title']}")
69
+
70
+ if __name__ == "__main__":
71
+ asyncio.run(main())
72
+ ```
73
+
74
+ ## Available Filters
75
+
76
+ Pass these constants into the `sp` parameter of the `search()` method.
77
+
78
+ ### Duration: Medium (3 - 20 Minutes)
79
+ | Filter Attribute | Description |
80
+ | :--- | :--- |
81
+ | `Filters.medium_today` | Uploaded **Today** |
82
+ | `Filters.medium_this_week` | Uploaded **This Week** |
83
+ | `Filters.medium_this_month` | Uploaded **This Month** |
84
+ | `Filters.medium_this_year` | Uploaded **This Year** |
85
+
86
+ ### Duration: Long (Over 20 Minutes)
87
+ | Filter Attribute | Description |
88
+ | :--- | :--- |
89
+ | `Filters.long_today` | Uploaded **Today** |
90
+ | `Filters.long_this_week` | Uploaded **This Week** |
91
+ | `Filters.long_this_month` | Uploaded **This Month** |
92
+ | `Filters.long_this_year` | Uploaded **This Year** |
93
+
94
+ ## Data Structure
95
+
96
+ The `.search()` method returns a list of dictionaries:
97
+
98
+ ```json
99
+ [
100
+ {
101
+ "id": "lDoYisPfcck",
102
+ "title": "Hack the planet! LangGraph AI HackBot Dev & Q/A",
103
+ "duration": "1:05:23",
104
+ "views": "1.2K views",
105
+ "url_suffix": "/watch?v=lDoYisPfcck"
106
+ }
107
+ ]
108
+ ```
109
+
110
+ ## Dependencies
111
+ - `aiohttp` (for async requests)
112
+
113
+ ## License
114
+ MIT License. See LICENSE file for details.
@@ -16,38 +16,40 @@ class Filters:
16
16
  long_this_month = "EgYIBBABGAI="
17
17
  long_this_year = "EgYIBRABGAI="
18
18
 
19
+
19
20
  class YouTubeSearch:
20
- def __init__(self, keywords: str, sp: str = None, limit: int = 15):
21
+ def __init__(self):
21
22
  """
22
- Initialize the search parameters.
23
- Note: No network request happens here. Call .search() to fetch data.
23
+ Initialize the YouTubeSearch client.
24
+ The client is stateless; parameters are passed to the search method.
24
25
  """
25
- self.keywords = keywords.replace(" ", "+")
26
- self.sp = sp
27
- self.limit = limit
28
- self.source = None
29
26
  self.base_url = "https://www.youtube.com/results"
30
-
31
- async def _fetch_source(self):
32
- params = {"search_query": self.keywords}
33
- if self.sp:
34
- params["sp"] = self.sp
35
-
36
- headers = {
27
+ self.headers = {
37
28
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
38
29
  }
39
30
 
31
+ async def _fetch_source(self, keywords: str, sp: str = None):
32
+ params = {"search_query": keywords.replace(" ", "+")}
33
+ if sp:
34
+ params["sp"] = sp
35
+
40
36
  async with aiohttp.ClientSession() as session:
41
- async with session.get(self.base_url, params=params, headers=headers) as response:
37
+ async with session.get(self.base_url, params=params, headers=self.headers) as response:
42
38
  return await response.text()
43
39
 
44
- async def search(self):
40
+ async def search(self, keywords: str, sp: str = None, limit: int = 15):
45
41
  """
46
- Asynchronously fetches and parses the search results.
47
- Returns a list of videos.
42
+ Asynchronously fetches and parses search results for the given keywords.
43
+
44
+ Args:
45
+ keywords (str): The search query.
46
+ sp (str, optional): The filter string (use Filters class). Defaults to None.
47
+ limit (int, optional): Max number of results. Defaults to 15.
48
+
49
+ Returns:
50
+ list: A list of dictionaries containing video details.
48
51
  """
49
- if not self.source:
50
- self.source = await self._fetch_source()
52
+ source = await self._fetch_source(keywords, sp)
51
53
 
52
54
  # Regex to capture distinct JSON fields for ID, Title, Duration, and Views.
53
55
  pattern = (
@@ -58,11 +60,11 @@ class YouTubeSearch:
58
60
  r'.+?\"viewCountText\":\{\"simpleText\":\"(?P<views>.+?)\"\}'
59
61
  )
60
62
 
61
- matches = re.finditer(pattern, self.source)
63
+ matches = re.finditer(pattern, source)
62
64
 
63
65
  results = []
64
66
  for match in matches:
65
- if len(results) >= self.limit:
67
+ if len(results) >= limit:
66
68
  break
67
69
 
68
70
  data = match.groupdict()
@@ -79,7 +81,16 @@ class YouTubeSearch:
79
81
  # --- Usage Example (Async) ---
80
82
  # import asyncio
81
83
  # async def main():
82
- # yt = YouTubeSearch("LangGraph", sp=Filters.long_this_week)
83
- # videos = await yt.search()
84
- # print(videos)
84
+ # yt = YouTubeSearch()
85
+ #
86
+ # # Search 1: Long videos about LangGraph
87
+ # print("Searching LangGraph...")
88
+ # videos1 = await yt.search("LangGraph", sp=Filters.long_this_week, limit=5)
89
+ # print(f"Found {len(videos1)} videos")
90
+ #
91
+ # # Search 2: Short Python tutorials (reusing the same instance)
92
+ # print("Searching Python...")
93
+ # videos2 = await yt.search("Python", sp=Filters.medium_today, limit=3)
94
+ # print(f"Found {len(videos2)} videos")
95
+ #
85
96
  # asyncio.run(main())
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: py-youtube-search
3
+ Version: 0.2.2
4
+ Summary: A lightweight, regex-based YouTube search library without API keys.
5
+ Home-page: https://github.com/VishvaRam/py-youtube-search
6
+ Author: VishvaRam
7
+ Author-email: murthyvishva@gmail.com
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: aiohttp>=3.8.0
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: requires-dist
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # py-youtube-search
27
+
28
+ A lightweight, asynchronous Python library to search YouTube videos programmatically without an API key.
29
+ It scrapes search results using `aiohttp` and `re`, making it fast, robust, and perfect for high-performance applications.
30
+
31
+ ## Features
32
+
33
+ - **Async Support**: Fully asynchronous using `aiohttp` for non-blocking execution.
34
+ - **Reusable Client**: Create a single instance and run multiple searches with different configurations.
35
+ - **No API Key Required**: Search YouTube directly without setting up Google Cloud projects.
36
+ - **Advanced Filtering**: Built-in support for duration (Medium 3-20m, Long >20m) and upload date filters.
37
+ - **Rich Data Extraction**: Extracts Video ID, Title, Duration, and View Count using optimized regex.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install py-youtube-search
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ### 1. Basic Async Search
48
+ Initialize the client once and run multiple searches.
49
+
50
+ ```python
51
+ import asyncio
52
+ from py_youtube_search import YouTubeSearch
53
+
54
+ async def main():
55
+ # 1. Initialize the client (reusable)
56
+ yt = YouTubeSearch()
57
+
58
+ # 2. Run a search
59
+ videos = await yt.search("Python async tutorials", limit=5)
60
+
61
+ for v in videos:
62
+ print(f"Title: {v['title']}")
63
+ print(f"Duration: {v['duration']}")
64
+ print(f"Views: {v['views']}")
65
+ print(f"Link: https://www.youtube.com/watch?v={v['id']}\n")
66
+
67
+ if __name__ == "__main__":
68
+ asyncio.run(main())
69
+ ```
70
+
71
+ ### 2. Advanced Search with Filters
72
+ Search for specific content, like long-form videos (>20m) uploaded this week.
73
+
74
+ ```python
75
+ import asyncio
76
+ from py_youtube_search import YouTubeSearch, Filters
77
+
78
+ async def main():
79
+ yt = YouTubeSearch()
80
+
81
+ # Search 1: Long videos about LangGraph
82
+ print("Searching for LangGraph...")
83
+ videos = await yt.search("LangGraph", sp=Filters.long_this_week, limit=3)
84
+
85
+ for v in videos:
86
+ print(f"🎥 {v['title']} | ⏱ {v['duration']} | 👁 {v['views']}")
87
+
88
+ # Search 2: Reusing the same client for a different query
89
+ print("\nSearching for Python...")
90
+ videos_py = await yt.search("Python 3.12", sp=Filters.medium_today, limit=3)
91
+
92
+ for v in videos_py:
93
+ print(f"🐍 {v['title']}")
94
+
95
+ if __name__ == "__main__":
96
+ asyncio.run(main())
97
+ ```
98
+
99
+ ## Available Filters
100
+
101
+ Pass these constants into the `sp` parameter of the `search()` method.
102
+
103
+ ### Duration: Medium (3 - 20 Minutes)
104
+ | Filter Attribute | Description |
105
+ | :--- | :--- |
106
+ | `Filters.medium_today` | Uploaded **Today** |
107
+ | `Filters.medium_this_week` | Uploaded **This Week** |
108
+ | `Filters.medium_this_month` | Uploaded **This Month** |
109
+ | `Filters.medium_this_year` | Uploaded **This Year** |
110
+
111
+ ### Duration: Long (Over 20 Minutes)
112
+ | Filter Attribute | Description |
113
+ | :--- | :--- |
114
+ | `Filters.long_today` | Uploaded **Today** |
115
+ | `Filters.long_this_week` | Uploaded **This Week** |
116
+ | `Filters.long_this_month` | Uploaded **This Month** |
117
+ | `Filters.long_this_year` | Uploaded **This Year** |
118
+
119
+ ## Data Structure
120
+
121
+ The `.search()` method returns a list of dictionaries:
122
+
123
+ ```json
124
+ [
125
+ {
126
+ "id": "lDoYisPfcck",
127
+ "title": "Hack the planet! LangGraph AI HackBot Dev & Q/A",
128
+ "duration": "1:05:23",
129
+ "views": "1.2K views",
130
+ "url_suffix": "/watch?v=lDoYisPfcck"
131
+ }
132
+ ]
133
+ ```
134
+
135
+ ## Dependencies
136
+ - `aiohttp` (for async requests)
137
+
138
+ ## License
139
+ MIT License. See LICENSE file for details.
@@ -4,4 +4,5 @@ py_youtube_search/__init__.py
4
4
  py_youtube_search.egg-info/PKG-INFO
5
5
  py_youtube_search.egg-info/SOURCES.txt
6
6
  py_youtube_search.egg-info/dependency_links.txt
7
+ py_youtube_search.egg-info/requires.txt
7
8
  py_youtube_search.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ aiohttp>=3.8.0
@@ -5,13 +5,16 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="py-youtube-search",
8
- version="0.2.0",
9
- author="VishvaRam", # <--- Change this
10
- author_email="murthyvishva@gmail.com", # <--- Change this
8
+ version="0.2.2",
9
+ author="VishvaRam",
10
+ install_requires=[
11
+ "aiohttp>=3.8.0",
12
+ ],
13
+ author_email="murthyvishva@gmail.com",
11
14
  description="A lightweight, regex-based YouTube search library without API keys.",
12
15
  long_description=long_description,
13
16
  long_description_content_type="text/markdown",
14
- url="https://github.com/VishvaRam/py-youtube-search", # <--- Change this
17
+ url="https://github.com/VishvaRam/py-youtube-search",
15
18
  packages=find_packages(),
16
19
  classifiers=[
17
20
  "Programming Language :: Python :: 3",
@@ -19,4 +22,5 @@ setup(
19
22
  "Operating System :: OS Independent",
20
23
  ],
21
24
  python_requires='>=3.6',
25
+ license="MIT",
22
26
  )
@@ -1,144 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: py-youtube-search
3
- Version: 0.2.0
4
- Summary: A lightweight, regex-based YouTube search library without API keys.
5
- Home-page: https://github.com/VishvaRam/py-youtube-search
6
- Author: VishvaRam
7
- Author-email: murthyvishva@gmail.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.6
12
- Description-Content-Type: text/markdown
13
- Dynamic: author
14
- Dynamic: author-email
15
- Dynamic: classifier
16
- Dynamic: description
17
- Dynamic: description-content-type
18
- Dynamic: home-page
19
- Dynamic: requires-python
20
- Dynamic: summary
21
-
22
- # py-youtube-search
23
-
24
- A lightweight, zero-dependency Python library to search YouTube videos programmatically without an API key. This library uses standard Python libraries (`urllib` and `re`) to scrape search results, making it fast, robust, and easy to integrate into any project.
25
-
26
- ## Features
27
-
28
- - **No API Key Required**: Search YouTube directly without setting up Google Cloud projects or billing.
29
- - **Zero External Dependencies**: Built entirely using Python's standard library (`urllib`, `re`). No `requests`, `selenium`, or `beautifulsoup` needed.
30
- - **Advanced Filtering**: Built-in support for duration (Medium 3-20m, Long >20m) and upload date filters (Today, Week, Month, Year).
31
- - **Rich Data Extraction**: Robustly extracts Video ID, Title, Duration, and View Count.
32
-
33
- ## Installation
34
-
35
- You can install the package via pip:
36
-
37
- ```bash
38
- pip install py-youtube-search
39
- ```
40
-
41
- ## Quick Start
42
-
43
- ### 1. Basic Search
44
- Fetch the top results for any keyword.
45
-
46
- ```python
47
- from py_youtube_search import YouTubeSearch
48
-
49
- # Search for the top 5 results for "Python tutorials"
50
- search = YouTubeSearch("Python tutorials", limit=5)
51
- videos = search.videos()
52
-
53
- for v in videos:
54
- print(f"Title: {v['title']}")
55
- print(f"Duration: {v['duration']}")
56
- print(f"Views: {v['views']}")
57
- print(f"Link: https://www.youtube.com/watch?v={v['id']}\n")
58
- ```
59
-
60
- ### 2. Advanced Search with Filters
61
- Search for specific types of content, such as long-form tutorials uploaded this week.
62
-
63
- ```python
64
- from py_youtube_search import YouTubeSearch, Filters
65
-
66
- # Search for "LangGraph" videos over 20 minutes long, uploaded this week
67
- # Use the Filters class to access constants
68
- search = YouTubeSearch("LangGraph", sp=Filters.long_this_week, limit=3)
69
- videos = search.videos()
70
-
71
- for v in videos:
72
- print(f"🎥 {v['title']} | ⏱ {v['duration']} | 👁 {v['views']}")
73
- ```
74
-
75
- ## Available Filters
76
-
77
- You can access these filters using the `Filters` class (e.g., `Filters.long_today`).
78
-
79
- ### Duration: Medium (3 - 20 Minutes)
80
- | Filter Attribute | Description |
81
- | :--- | :--- |
82
- | `Filters.medium_today` | Uploaded **Today** |
83
- | `Filters.medium_this_week` | Uploaded **This Week** |
84
- | `Filters.medium_this_month` | Uploaded **This Month** |
85
- | `Filters.medium_this_year` | Uploaded **This Year** |
86
-
87
- ### Duration: Long (Over 20 Minutes)
88
- | Filter Attribute | Description |
89
- | :--- | :--- |
90
- | `Filters.long_today` | Uploaded **Today** |
91
- | `Filters.long_this_week` | Uploaded **This Week** |
92
- | `Filters.long_this_month` | Uploaded **This Month** |
93
- | `Filters.long_this_year` | Uploaded **This Year** |
94
-
95
- ## Data Structure
96
-
97
- The `videos()` method returns a list of dictionaries with the following structure:
98
-
99
- ```json
100
- [
101
- {
102
- "id": "lDoYisPfcck",
103
- "title": "Hack the planet! LangGraph AI HackBot Dev & Q/A",
104
- "duration": "1:05:23",
105
- "views": "1.2K views",
106
- "url_suffix": "/watch?v=lDoYisPfcck"
107
- },
108
- {
109
- "id": "5LXLmUsEM20",
110
- "title": "LangGraph Workflow Patterns - Part 1/10",
111
- "duration": "42 seconds",
112
- "views": "500 views",
113
- "url_suffix": "/watch?v=5LXLmUsEM20"
114
- }
115
- ]
116
- ```
117
-
118
- ## License
119
-
120
- This project is licensed under the MIT License - see below for details.
121
-
122
- ```text
123
- MIT License
124
-
125
- Copyright (c) 2026
126
-
127
- Permission is hereby granted, free of charge, to any person obtaining a copy
128
- of this software and associated documentation files (the "Software"), to deal
129
- in the Software without restriction, including without limitation the rights
130
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
131
- copies of the Software, and to permit persons to whom the Software is
132
- furnished to do so, subject to the following conditions:
133
-
134
- The above copyright notice and this permission notice shall be included in all
135
- copies or substantial portions of the Software.
136
-
137
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
138
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
139
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
140
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
141
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
142
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
143
- SOFTWARE.
144
- ```
@@ -1,123 +0,0 @@
1
- # py-youtube-search
2
-
3
- A lightweight, zero-dependency Python library to search YouTube videos programmatically without an API key. This library uses standard Python libraries (`urllib` and `re`) to scrape search results, making it fast, robust, and easy to integrate into any project.
4
-
5
- ## Features
6
-
7
- - **No API Key Required**: Search YouTube directly without setting up Google Cloud projects or billing.
8
- - **Zero External Dependencies**: Built entirely using Python's standard library (`urllib`, `re`). No `requests`, `selenium`, or `beautifulsoup` needed.
9
- - **Advanced Filtering**: Built-in support for duration (Medium 3-20m, Long >20m) and upload date filters (Today, Week, Month, Year).
10
- - **Rich Data Extraction**: Robustly extracts Video ID, Title, Duration, and View Count.
11
-
12
- ## Installation
13
-
14
- You can install the package via pip:
15
-
16
- ```bash
17
- pip install py-youtube-search
18
- ```
19
-
20
- ## Quick Start
21
-
22
- ### 1. Basic Search
23
- Fetch the top results for any keyword.
24
-
25
- ```python
26
- from py_youtube_search import YouTubeSearch
27
-
28
- # Search for the top 5 results for "Python tutorials"
29
- search = YouTubeSearch("Python tutorials", limit=5)
30
- videos = search.videos()
31
-
32
- for v in videos:
33
- print(f"Title: {v['title']}")
34
- print(f"Duration: {v['duration']}")
35
- print(f"Views: {v['views']}")
36
- print(f"Link: https://www.youtube.com/watch?v={v['id']}\n")
37
- ```
38
-
39
- ### 2. Advanced Search with Filters
40
- Search for specific types of content, such as long-form tutorials uploaded this week.
41
-
42
- ```python
43
- from py_youtube_search import YouTubeSearch, Filters
44
-
45
- # Search for "LangGraph" videos over 20 minutes long, uploaded this week
46
- # Use the Filters class to access constants
47
- search = YouTubeSearch("LangGraph", sp=Filters.long_this_week, limit=3)
48
- videos = search.videos()
49
-
50
- for v in videos:
51
- print(f"🎥 {v['title']} | ⏱ {v['duration']} | 👁 {v['views']}")
52
- ```
53
-
54
- ## Available Filters
55
-
56
- You can access these filters using the `Filters` class (e.g., `Filters.long_today`).
57
-
58
- ### Duration: Medium (3 - 20 Minutes)
59
- | Filter Attribute | Description |
60
- | :--- | :--- |
61
- | `Filters.medium_today` | Uploaded **Today** |
62
- | `Filters.medium_this_week` | Uploaded **This Week** |
63
- | `Filters.medium_this_month` | Uploaded **This Month** |
64
- | `Filters.medium_this_year` | Uploaded **This Year** |
65
-
66
- ### Duration: Long (Over 20 Minutes)
67
- | Filter Attribute | Description |
68
- | :--- | :--- |
69
- | `Filters.long_today` | Uploaded **Today** |
70
- | `Filters.long_this_week` | Uploaded **This Week** |
71
- | `Filters.long_this_month` | Uploaded **This Month** |
72
- | `Filters.long_this_year` | Uploaded **This Year** |
73
-
74
- ## Data Structure
75
-
76
- The `videos()` method returns a list of dictionaries with the following structure:
77
-
78
- ```json
79
- [
80
- {
81
- "id": "lDoYisPfcck",
82
- "title": "Hack the planet! LangGraph AI HackBot Dev & Q/A",
83
- "duration": "1:05:23",
84
- "views": "1.2K views",
85
- "url_suffix": "/watch?v=lDoYisPfcck"
86
- },
87
- {
88
- "id": "5LXLmUsEM20",
89
- "title": "LangGraph Workflow Patterns - Part 1/10",
90
- "duration": "42 seconds",
91
- "views": "500 views",
92
- "url_suffix": "/watch?v=5LXLmUsEM20"
93
- }
94
- ]
95
- ```
96
-
97
- ## License
98
-
99
- This project is licensed under the MIT License - see below for details.
100
-
101
- ```text
102
- MIT License
103
-
104
- Copyright (c) 2026
105
-
106
- Permission is hereby granted, free of charge, to any person obtaining a copy
107
- of this software and associated documentation files (the "Software"), to deal
108
- in the Software without restriction, including without limitation the rights
109
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
110
- copies of the Software, and to permit persons to whom the Software is
111
- furnished to do so, subject to the following conditions:
112
-
113
- The above copyright notice and this permission notice shall be included in all
114
- copies or substantial portions of the Software.
115
-
116
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
117
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
118
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
119
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
120
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
121
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
122
- SOFTWARE.
123
- ```
@@ -1,144 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: py-youtube-search
3
- Version: 0.2.0
4
- Summary: A lightweight, regex-based YouTube search library without API keys.
5
- Home-page: https://github.com/VishvaRam/py-youtube-search
6
- Author: VishvaRam
7
- Author-email: murthyvishva@gmail.com
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.6
12
- Description-Content-Type: text/markdown
13
- Dynamic: author
14
- Dynamic: author-email
15
- Dynamic: classifier
16
- Dynamic: description
17
- Dynamic: description-content-type
18
- Dynamic: home-page
19
- Dynamic: requires-python
20
- Dynamic: summary
21
-
22
- # py-youtube-search
23
-
24
- A lightweight, zero-dependency Python library to search YouTube videos programmatically without an API key. This library uses standard Python libraries (`urllib` and `re`) to scrape search results, making it fast, robust, and easy to integrate into any project.
25
-
26
- ## Features
27
-
28
- - **No API Key Required**: Search YouTube directly without setting up Google Cloud projects or billing.
29
- - **Zero External Dependencies**: Built entirely using Python's standard library (`urllib`, `re`). No `requests`, `selenium`, or `beautifulsoup` needed.
30
- - **Advanced Filtering**: Built-in support for duration (Medium 3-20m, Long >20m) and upload date filters (Today, Week, Month, Year).
31
- - **Rich Data Extraction**: Robustly extracts Video ID, Title, Duration, and View Count.
32
-
33
- ## Installation
34
-
35
- You can install the package via pip:
36
-
37
- ```bash
38
- pip install py-youtube-search
39
- ```
40
-
41
- ## Quick Start
42
-
43
- ### 1. Basic Search
44
- Fetch the top results for any keyword.
45
-
46
- ```python
47
- from py_youtube_search import YouTubeSearch
48
-
49
- # Search for the top 5 results for "Python tutorials"
50
- search = YouTubeSearch("Python tutorials", limit=5)
51
- videos = search.videos()
52
-
53
- for v in videos:
54
- print(f"Title: {v['title']}")
55
- print(f"Duration: {v['duration']}")
56
- print(f"Views: {v['views']}")
57
- print(f"Link: https://www.youtube.com/watch?v={v['id']}\n")
58
- ```
59
-
60
- ### 2. Advanced Search with Filters
61
- Search for specific types of content, such as long-form tutorials uploaded this week.
62
-
63
- ```python
64
- from py_youtube_search import YouTubeSearch, Filters
65
-
66
- # Search for "LangGraph" videos over 20 minutes long, uploaded this week
67
- # Use the Filters class to access constants
68
- search = YouTubeSearch("LangGraph", sp=Filters.long_this_week, limit=3)
69
- videos = search.videos()
70
-
71
- for v in videos:
72
- print(f"🎥 {v['title']} | ⏱ {v['duration']} | 👁 {v['views']}")
73
- ```
74
-
75
- ## Available Filters
76
-
77
- You can access these filters using the `Filters` class (e.g., `Filters.long_today`).
78
-
79
- ### Duration: Medium (3 - 20 Minutes)
80
- | Filter Attribute | Description |
81
- | :--- | :--- |
82
- | `Filters.medium_today` | Uploaded **Today** |
83
- | `Filters.medium_this_week` | Uploaded **This Week** |
84
- | `Filters.medium_this_month` | Uploaded **This Month** |
85
- | `Filters.medium_this_year` | Uploaded **This Year** |
86
-
87
- ### Duration: Long (Over 20 Minutes)
88
- | Filter Attribute | Description |
89
- | :--- | :--- |
90
- | `Filters.long_today` | Uploaded **Today** |
91
- | `Filters.long_this_week` | Uploaded **This Week** |
92
- | `Filters.long_this_month` | Uploaded **This Month** |
93
- | `Filters.long_this_year` | Uploaded **This Year** |
94
-
95
- ## Data Structure
96
-
97
- The `videos()` method returns a list of dictionaries with the following structure:
98
-
99
- ```json
100
- [
101
- {
102
- "id": "lDoYisPfcck",
103
- "title": "Hack the planet! LangGraph AI HackBot Dev & Q/A",
104
- "duration": "1:05:23",
105
- "views": "1.2K views",
106
- "url_suffix": "/watch?v=lDoYisPfcck"
107
- },
108
- {
109
- "id": "5LXLmUsEM20",
110
- "title": "LangGraph Workflow Patterns - Part 1/10",
111
- "duration": "42 seconds",
112
- "views": "500 views",
113
- "url_suffix": "/watch?v=5LXLmUsEM20"
114
- }
115
- ]
116
- ```
117
-
118
- ## License
119
-
120
- This project is licensed under the MIT License - see below for details.
121
-
122
- ```text
123
- MIT License
124
-
125
- Copyright (c) 2026
126
-
127
- Permission is hereby granted, free of charge, to any person obtaining a copy
128
- of this software and associated documentation files (the "Software"), to deal
129
- in the Software without restriction, including without limitation the rights
130
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
131
- copies of the Software, and to permit persons to whom the Software is
132
- furnished to do so, subject to the following conditions:
133
-
134
- The above copyright notice and this permission notice shall be included in all
135
- copies or substantial portions of the Software.
136
-
137
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
138
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
139
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
140
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
141
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
142
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
143
- SOFTWARE.
144
- ```