-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
from __modules__.header_module import app_header | ||
from __modules__.youtube_search_Module import media_search | ||
import asyncio | ||
|
||
app_header() | ||
|
||
def main(): | ||
return | ||
async def main(): | ||
app_header() | ||
await media_search() | ||
|
||
if __name__ == '__main__': | ||
main() | ||
asyncio.run(main()) |
Binary file added
BIN
+2.23 KB
...dia Searcher and Downloader/__modules__/__pycache__/youtube_search_Module.cpython-312.pyc
Binary file not shown.
38 changes: 0 additions & 38 deletions
38
Project 14 - Media Searcher and Downloader/__modules__/youtube_module.py
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
Project 14 - Media Searcher and Downloader/__modules__/youtube_search_Module.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pytube import Search | ||
from pytube import YouTube | ||
import asyncio | ||
|
||
async def search_query(user_query, r_limit): | ||
q = Search(user_query) | ||
results = [] | ||
|
||
while len(results) < r_limit: | ||
next_results = q.results | ||
if not next_results: | ||
break | ||
results.extend(next_results) | ||
|
||
search_term = user_query | ||
video_info = [{'title': video.title, 'video_id': video.video_id, 'thumbnail': video.thumbnail_url} for video in results] | ||
|
||
return search_term, video_info[:r_limit] | ||
|
||
async def media_search(): | ||
try: | ||
user_input = input("Search here : ") | ||
result_limit = int(input("Set Result Limit : ")) | ||
query_results = await search_query(user_input, result_limit) | ||
|
||
search_term, video_info = query_results | ||
print() | ||
print('-------------------------------------- Result ---------------------------------------') | ||
print(f'Search Term : {search_term}') | ||
print() | ||
|
||
for num, video_info in enumerate(video_info, start=1): | ||
print(f'{num} | Title ==> {video_info['title']} <==\n | URL : https://www.youtube.com/watch?v={video_info['video_id']}\n | Thumbnail : {video_info['thumbnail']}\n-------------------------------------------------------------------------------\n') | ||
except Exception as e: | ||
print(f"Error occurred : {e}") | ||
|