Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Time Marker Detection in Episode Descriptions #1208

Merged
merged 3 commits into from
May 21, 2024

Conversation

mfcar
Copy link
Contributor

@mfcar mfcar commented May 19, 2024

Here's the corrected text for your pull request:

Several podcast apps, such as Overcast and Pocket Cast, have a feature that detects Time Markers in the episode description. This feature provides a way to jump directly to that time. It's very similar to chapters, but the time markers aren't embedded in the files; they are automatically detected from the description.

Screenshot 2024-05-19 at 14 23 50

This PR adds support for detecting time markers in the AudioBookShelf app as well.

image

The detector identifies time markers in multiple formats (at least minutes and seconds):

H:M:SS
H:MM:SS
HH:MM:SS
H:M:SS

Demo

Screen.Recording.2024-05-19.at.14.16.51.mov

@advplyr
Copy link
Owner

advplyr commented May 19, 2024

This is great. The RSS feed for Syntax has an issue because they put a link around their timestamps.
https://feed.syntax.fm/rss

image

I couldn't think of a way to handle false positives better. The regex gets complicated when trying to handle these different cases so I'm not sure if it is worth it.

image

@nichwall
Copy link
Contributor

Maybe just adding something like the following to ignore matches that have more than 2 digits on the end parts by checking that the preceding or following character is not a digit (like the link with a port in it). Not sure if that's worth it or how often ports would show up in a link.

Before: \b(?<!\d)
After: ?(?!\d)\b

@mfcar
Copy link
Contributor Author

mfcar commented May 20, 2024

Thanks @advplyr and @nichwall for the feedback.

I was investigating the Syntax RSS feed, and they use an anchor link for the time marker, but the anchor only works on their page. I tested the same feed on other apps and got the following results:

  1. PocketCasts: Uses a different color for the anchor links, but when you tap them, nothing happens.
  2. Overcast: Uses the same color for the external links, and like PocketCasts, tapping them does nothing.
  3. Apple Podcasts: Doesn't render anchor links, only regular links.
Screenshot 2024-05-20 at 22 52 06

Based on this, I made some adjustments to the code to handle anchor links in the detector. If a time marker is inside an anchor link (which won't work because we're not on the website page), I replace it with a detectable time marker (the other links remain unchanged).

Screenshot 2024-05-20 at 08 12 42

Based on advplyr's test cases, I tested with additional edge cases, and the detector worked well. As nichwall suggested, I changed the script to avoid URLs with a port value, but if the URL contains at least two colons, I can't detect this, or if it is an plain anchor url

Here are some tests that I generated to check:

Screenshot 2024-05-20 at 23 04 41

@advplyr
Copy link
Owner

advplyr commented May 21, 2024

Great, thanks!

@advplyr advplyr merged commit f047f6a into advplyr:master May 21, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants