Skip to content

Commit

Permalink
added video id to search results
Browse files Browse the repository at this point in the history
  • Loading branch information
NotJoeMartinez committed Sep 6, 2024
1 parent cafd46f commit 2df534d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions yt_fts/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def print_fts_res(self):
metadata = quote["metadata"]
video_name = metadata["video_title"]
video_date = metadata["video_date"]
video_id = quote["video_id"]
quote_data = {
"quote": quote["subs"],
"time_stamp": quote["time_stamp"],
Expand All @@ -167,8 +168,8 @@ def print_fts_res(self):
if channel_name not in fts_dict:
fts_dict[channel_name] = {}
if (video_name, video_date) not in fts_dict[channel_name]:
fts_dict[channel_name][(video_name, video_date)] = []
fts_dict[channel_name][(video_name, video_date)].append(quote_data)
fts_dict[channel_name][(video_name, video_date, video_id)] = []
fts_dict[channel_name][(video_name, video_date, video_id)].append(quote_data)

# Sort the list by the total number of quotes in each channel
channel_list = list(fts_dict.items())
Expand All @@ -182,8 +183,8 @@ def print_fts_res(self):
video_list = list(videos.items())
video_list.sort(key=lambda x: len(x[1]))

for (video_name, video_date), quotes in video_list:
console.print(f" [bold][blue]{video_name}[/blue][/bold] ({video_date})")
for (video_name, video_date, video_id), quotes in video_list:
console.print(f"{video_id} ({video_date}): \"[bold][blue]{video_name}[/blue][/bold]\"")
console.print("")

# Sort the quotes by timestamp
Expand Down
4 changes: 3 additions & 1 deletion yt_fts/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import yt_dlp
from rich.console import Console
from rich.markdown import Markdown
from urllib.parse import urlparse, parse_qs

from .config import get_db_path
Expand Down Expand Up @@ -60,7 +61,8 @@ def summarize_video(self):
]

summary_text = self.get_completion(messages)
console.print(summary_text)
md = Markdown(summary_text)
self.console.print(md)


def get_completion(self, messages: list) -> str:
Expand Down

0 comments on commit 2df534d

Please sign in to comment.