Skip to content

Commit cd4d9b3

Browse files
committed
Adding 14th Project
1 parent 265d3f2 commit cd4d9b3

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __modules__.header_module import app_header
2+
3+
app_header()
4+
5+
def main():
6+
return
7+
if __name__ == '__main__':
8+
main()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import sys
2+
import time
3+
4+
def app_header():
5+
input_str = '''===========================================\n\tMedia Search and Downloader\n==========================================='''
6+
sys.stdout.write('\n')
7+
for c in input_str:
8+
if c == '=':
9+
time.sleep(0.01)
10+
else:
11+
time.sleep(0.1)
12+
13+
sys.stdout.write(c)
14+
sys.stdout.flush()
15+
sys.stdout.write('\n')
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from pytube import Search
2+
from pytube import YouTube
3+
import os
4+
import sys
5+
6+
sys.stderr = open(os.devnull, 'w')
7+
8+
def search_query(user_query, r_limit):
9+
q = Search(user_query)
10+
results = []
11+
12+
while len(results) < r_limit:
13+
next_results = q.results
14+
if not next_results:
15+
break
16+
results.extend(next_results)
17+
18+
search_term = user_query
19+
video_info = [{'title': video.title, 'video_id': video.video_id, 'thumbnail': video.thumbnail_url} for video in results]
20+
21+
return search_term, video_info[:r_limit]
22+
23+
user_input = input("Search here : ")
24+
result_limit = int(input("Set Result Limit : "))
25+
26+
try:
27+
query_results = search_query(user_input, result_limit)
28+
29+
search_term, video_info = query_results
30+
print(f'Search Term : {search_term}')
31+
32+
for num, video_info in enumerate(video_info, start=1):
33+
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')
34+
except Exception as e:
35+
print(f"Error occurred : {e}")
36+
37+
sys.stderr.close()
38+
sys.stderr = sys.__stderr__

0 commit comments

Comments
 (0)