Skip to content

Commit 0ac8a9a

Browse files
committed
Add exception handling on youtube_helper & Resolve text_output appendment problem
1 parent affd2b7 commit 0ac8a9a

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
__pycache__/
2-
Old Files/
2+
Old Files/
3+
venv/
4+
docs/

files/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
- https://www.youtube.com/watch?v=gGGPTskb7c8 Starting A Serious Web Development Project - Traversy Media
2-
- https://www.youtube.com/watch?v=lKr3wa24NFg What is a deep learning architect and the interview process. With Adam Grzywaczewski (NVIDIA) - What's AI by Louis Bouchard
2+
- https://www.youtube.com/watch?v=lKr3wa24NFg What is a deep learning architect and the interview process. With Adam Grzywaczewski (NVIDIA) - What's AI by Louis Bouchard

notion_modifier.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ def add_youtube_title_and_channel_name(text):
156156
# Append to text_output
157157
text_output = f"{text_output}- {url} {title} - {channel_name}\n"
158158
else:
159-
text_output = f"{data}\n"
160-
159+
text_output = f"{text_output}{data}\n"
160+
161161
# Get processing time
162162
time.sleep(1) # store end time
163163
end = time.time() # total time taken

youtube_helper.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ def get_title(url):
1414
title = ""
1515

1616
# Check if the URL is a playlist or a video
17-
if 'playlist' in url:
18-
# Get playlist data and title
19-
title = Playlist(url).title
20-
else:
21-
# Get video data and title
22-
title = YouTube(url).title
17+
try:
18+
if 'playlist' in url:
19+
# Get playlist data and title
20+
title = Playlist(url).title
21+
else:
22+
# Get video data and title
23+
title = YouTube(url).title
24+
except Exception as e:
25+
pass
2326

2427
# Return the title
2528
return title
@@ -38,12 +41,15 @@ def get_channel_name(url):
3841
channel_name = ""
3942

4043
# Check if the URL is a playlist or a video
41-
if 'playlist' in url:
42-
# Get playlist data and owner channel name
43-
channel_name = Playlist(url).owner
44-
else:
45-
# Get video data and author channel name
46-
channel_name = YouTube(url).author
44+
try:
45+
if 'playlist' in url:
46+
# Get playlist data and owner channel name
47+
channel_name = Playlist(url).owner
48+
else:
49+
# Get video data and author channel name
50+
channel_name = YouTube(url).author
51+
except Exception as e:
52+
pass
4753

4854
# Return the channel name
4955
return channel_name

0 commit comments

Comments
 (0)