Skip to content

Commit

Permalink
add google slides - fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
milovate committed Nov 13, 2024
1 parent 958a2e7 commit 3e70e03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions daras_ai_v2/gdrive_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
def is_gdrive_url(f: furl) -> bool:
return f.host in ["drive.google.com", "docs.google.com"]

def is_gdrive_presentation_url(f: furl) -> bool:
return f.host in ["drive.google.com", "docs.google.com"] and "presentation" in f.path.segments

def url_to_gdrive_file_id(f: furl) -> str:
# extract google drive file ID
Expand Down
6 changes: 6 additions & 0 deletions daras_ai_v2/vector_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
from daras_ai_v2.gdrive_downloader import (
gdrive_download,
is_gdrive_url,
is_gdrive_presentation_url,
url_to_gdrive_file_id,
gdrive_metadata,
)
Expand Down Expand Up @@ -972,6 +973,11 @@ def get_pdf_num_pages(f_bytes: bytes) -> int:


def add_page_number_to_pdf(url: str | furl, page_num: int) -> furl:

# if it's a google drive presentation, add the slide number to the fragment
if is_gdrive_presentation_url(furl(url)):
return furl(url).set(fragment_args={"slide": page_num} if page_num else {})

return furl(url).set(fragment_args={"page": page_num} if page_num else {})


Expand Down

0 comments on commit 3e70e03

Please sign in to comment.