agzam / youtube-sub-extractor.el

Extract YouTube video subtitles
GNU General Public License v3.0
30 stars 1 forks source link

Removing hours from timestamps breaks playback with mpv.el #18

Open NapoleonWils0n opened 1 year ago

NapoleonWils0n commented 1 year ago

HI Mate, removing the hours from timestamps for videos under 1 hour breaks playback with mpv.el

mpv.el can control mpv using its rpc interface so you can jump to a position in the video when your cursor is over a timestamp, using a keyboard shortcut

but it needs ttimestamp to be in hours, minutes, seconds 00:00:00

after some blundering about i found this line was causing the issue

line 214

(ts (substring full-ts (if mins-only? 3 0) 8))

so i changed the code to this

(ts (substring full-ts (if mins-only? 0 0) 8))

You can use the mpv-play function to play a local file, or mpv-play-url to play a url like a youtube link i had to set the extractor timestamps to be displayed on left-side-text

(setq youtube-sub-extractor-timestamps 'left-side-text)

so i run youtube-extractor-extract-subs and paste in the url then i run mpv-play-url and paste in the same url, ill have to figure out how create one function thats runs both the commands, so you only have to paste the url in once

then in the youtube subs buffer i can place my cursor over a timestamp in the left column press a keyboard shortcut and mpv playing a youtube video will jump to that position in the video

if you set mpv to be an external browser and use the C-c C-o keyboard shortcur it will open another instance of mpv instead of jumping to that position in the open mpv player, thats why using mpv.el with youtube-sub-extractor is awesome

Another minor issue is it would be nice if there was a way to set the subs buffer to be fullsize, its a bit of pain to have to press crl x 1 everytime to get the buffer to go fullsize so you can read it

i fixed the issue by changing this line

line 238

from

(switch-to-buffer-other-window buf)

to

(pop-to-buffer-same-window buf)

Also the other issue i noticed was when you have the browser set to open links what would happen is that it would open new tabs everytime you pressed C-c C-o on a link

hope you dont mind the feedback, great package with a few tweaks does exactly what i was after ill make a video about using youtube-sub-extractor.el with mpv.el becuase its a really powerfull combination and allows you to search the subs and jump to that point in the video

youtube subs hours minutes seconds

mpv.el config

` (defun mpv-play-link (url &rest args) "" (interactive) (start-process "mpv" nil "mpv" url))

;;browse url open different browsers based on url (setq browse-url-handlers '(("https://www.youtube.com/.*" . mpv-play-link) ("." . browse-url-default-browser)))

`

agzam commented 1 year ago

Thank you for the detailed description of the problem. Also TIL about mpv.el. I'll check it out, sounds very interesting. And I'll try to find time to fix this issue.

NapoleonWils0n commented 1 year ago

HI Mate, hope i explained the issue properly

i made a video about using youtube-sub-extractor.el with mpv.el which shows how you can download the subs from youtube and then open the youtube url with mpv using mpv.el and then jump to any position in the stream using the timestamps, very cool

emacs youtube-sub-extractor.el and mpv.el

what i also do is save the youtube-sub-extractor buffer as text file and use a little shell script with awk i knocked up that converts the hours, minutes, seconds timestmaps to seconds

then extract the youtube id on the fist line of the title in brackets and batch create all the youtube share links with the seconds timestamps and save it as csv file

subs-yt-timestamp

output of subs-yt-timestamp script

https://youtu.be/qP_YcVnyX30?t=0 , https://youtu.be/qP_YcVnyX30?t=2 ,[Music] https://youtu.be/qP_YcVnyX30?t=12 ,[Music] here in which i wander around london and tell you fascinating facts don't forget https://youtu.be/qP_YcVnyX30?t=15 ,to hit the subscribe button if you enjoy the videos now i don't know what the