Tip jar

If you like CaB and wish to support it, you can use PayPal or KoFi. Thank you, and I hope you continue to enjoy the site - Neil.

Buy Me a Coffee at ko-fi.com

Support CaB

Recent

Welcome to Cook'd and Bomb'd. Please login or sign up.

April 27, 2024, 12:31:07 PM

Login with username, password and session length

Quick URL Record - How to pull subtitles

Started by Magnum Valentino, March 17, 2024, 08:43:26 AM

Previous topic - Next topic

Magnum Valentino

Hello all. Using the Quick URL Record that was linked here moons ago to get some stuff from iPlayer but I can't find any way to tailor its preferences. I'm trying to pull down the subtitles from the videos I'm extracting. It must be possible but I'm not knowledgable enough about how to go about it.

Any tips?

You might be better off using an alternative program like Get iPlayer Automator that lets you configure it from within the program. But if you're otherwise happy with Quick URL Record then you can edit the underlying script to enable subtitles.

Open up a Terminal window and paste the following command to make a backup of the script:

sudo cp /Applications/get_iplayer/Quick\ URL\ Record.app/Contents/Resources/script /Applications/get_iplayer/Quick\ URL\ Record.app/Contents/Resources/script.bak
It'll prompt you for a password -- enter your login password.

Now paste the following command into the Terminal:

sudo sed -i -e 's/get_iplayer --log-progress/get_iplayer --log-progress --subtitles/' /Applications/get_iplayer/Quick\ URL\ Record.app/Contents/Resources/script
This edits the script to add the --subtitles option when it runs get_iplayer.

To restore the script from the backed-up copy:

sudo cp /Applications/get_iplayer/Quick\ URL\ Record.app/Contents/Resources/script.bak /Applications/get_iplayer/Quick\ URL\ Record.app/Contents/Resources/script

Magnum Valentino

Holy jesus that worked perfectly.

My next issue is that all iPlayer subs have coding in the text to determine text colour which doesn't work properly outside of the iPlayer itself.

Is there a way to run a script that would scan a text file for any instances of something like "font color=f00000/font" and just remove that text? Is Terminal that capable?

Trying to take some of the manual labour out of all of this and learning something new every day.

Adding the '--subs-mono' option to the script should do the trick. It removes the colour and adds a '-' to the start of lines that indicate a new speaker (so the output is a little nicer than just stripping out the font tags).

Restore the backed-up file then run this:

sudo sed -i -e 's/get_iplayer --log-progress/get_iplayer --log-progress --subtitles --subs-mono/' /Applications/get_iplayer/Quick\ URL\ Record.app/Contents/Resources/script

This will work for any subtitles you download from now on. It doesn't help you fix the subtitles you've already downloaded though. To do that, you can tweak the command to just download the subtitles, and to overwrite any existing subtitle files, then re-download the broken/missing subs.

It's probably easiest doing this in a text editor (the automated commands are handy for one-shot changes but if you're chopping and changing then you may as well use an editor):

sudo nano /Applications/get_iplayer/Quick\ URL\ Record.app/Contents/Resources/script

Scroll down until you see the line:

cmd_base="/usr/local/bin/get_iplayer --log-progress --subtitles --subs-mono"

(It might not be the exact same set of options, depending on what you've changed so far.)

Tweak it as follows:

cmd_base="/usr/local/bin/get_iplayer --log-progress --subtitles-only --subs-mono --overwrite"

Hit Ctrl+X, then press Y to save and Enter to confirm the filename.

Now re-download anything that has broken or missing subtitles.

Once you've done all that, re-run the process of opening it in an editor and change the line back to:

cmd_base="/usr/local/bin/get_iplayer --log-progress --subtitles --subs-mono"

Quote from: Magnum Valentino on March 17, 2024, 06:47:51 PMMy next issue is that all iPlayer subs have coding in the text to determine text colour which doesn't work properly outside of the iPlayer itself.
get_iplayer has a --subs-monp option which makes it not add those tags. I think some other players support them, but I find them unconscionable since they're not part of the SRT format standard, so I always use the mono option. You need --subtitles as well.

You may also be interested in --subs-raw which makes it save subtitles in the original TTML format in addition to SRT (which get_iplayer produces by converting from TTML). This includes the colours and possibly some other things that don't get carried over to SRT, like when the subtitles are placed in a different posiiton to avoid obscuring something in the video. But not all players support the TTML format.

I'm not familiar with Quick URL Record but in the sed command posted above you should be able to just add --subs-mono and/or --subs-raw after --subtitles (separated by spaces). You'd have to restore the original file first before runnign the command again. Or you could just edit the file in a text editor, search for get_iplayer --log-progress and add the options you want.

Quote from: Magnum Valentino on March 17, 2024, 06:47:51 PMIs there a way to run a script that would scan a text file for any instances of something like "font color=f00000/font" and just remove that text? Is Terminal that capable?
That would be possible, but maybe just doing it for newly-downloaded subtitles is enough for you? You can re-download subtitles only by running get_iplayer directly with the --subtitles-only option. But if you do need to strip subtitles retrospectively I could look at exactly what format the tags take and work out a sed command to remove them.

Magnum Valentino

Thanks to you both, this has worked beautifully and I've only a handful of already-downloaded ones which I can easily run find/replace on in Word.

Cheers!

Sebastian Cobb

Worth notiing if you don't want a separate .srt there's also an embed option.

QuoteEmbedded soft subtitles
Use the --subs-embed option to embed soft subtitles in the MP4 output file. Embedded subtitles can be used by iTunes, Apple TV, and some other media players that do not support external .srt files. The external .srt files are still created. You can configure get_iplayer to embed subtitles with:

get_iplayer --prefs-add --subtitles --subs-embed
--subs-embed implies --subs-mono, so the external .srt files are formatted the same as the embedded subtitles. If you you add --subs-embed to your preferences as shown above, you do not need to add --subs-mono as well.
If you normally use --subs-embed but wish to create external .srt files with colour subtitles, use --subtitles-only --no-subs-embed --no-subs-mono --overwrite to re-download subtitles and replace the .srt files with the default colour subtitles.
Embedding is done by ffmpeg when converting the raw download to MP4, so there is a possibility that problems with the subtitles may prevent the MP4 conversion from completing.

Magnum Valentino