Skip to content

Commit

Permalink
Updating 14th Project
Browse files Browse the repository at this point in the history
  • Loading branch information
JawadSher committed Jul 15, 2024
1 parent f3a0129 commit 738257f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 42 deletions.
11 changes: 7 additions & 4 deletions Project 14 - Media Searcher and Downloader/Application.py
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 not shown.

This file was deleted.

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}")

0 comments on commit 738257f

Please sign in to comment.