Web Clipper Youtube template format duration

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

Things I have tried

About 3 months ago I started with Obsidian and frequently use Web Clipper.
Also found nice templates for specific sites, like Wikipedia, LinkedIn and Youtube.

For Yoube I found a nice template but want to use it as a source for modification into my own Youtbue-notes preferences:

The easy part was removing the time-stamp from property “” created" and limited it to a Dutch formatted date dd-mm-yyyy.

Then I wanted to modify the duration, from seconds to H:mm:ss.

Followed the Obsidian help: Help → Obsidian Web Clipper → Filters → duration:

"Converts ISO 8601 duration strings or seconds into formatted time strings. Uses tokens: HH (padded hours), H (hours), mm (padded minutes), m (minutes), ss (padded seconds), s (seconds).

“PT1H30M”|duration:“HH:mm:ss” returns “01:30:00”.
“3665”|duration:“H:mm:ss” returns “1:01:05”.
Setting duration without any parameters uses HH:mm:ss over 1 hour, mm:ss under 1 hour.
Supports both ISO 8601 duration strings (e.g., PT6702S, PT1H30M) and plain seconds.
"

Ended up in nearly endless number of permutations of number and place of quotation marks. and get it partially wordkinG: But I’m afraid to have to give up.

Tested this by duplicating the "duration"in the orgianal JSON-file and plying around with that “Format duration” property:

	{
		"name": "duration",
		"value": "{{schema:@VideoObject:duration|replace:\\\"PT\\\",\\\"\\\",\\\"S\\\",\\\"\\\"}}",
		"type": "text"
	},
	{
		"name": "format duration",
		"value": "{{schema:@VideoObject:duration|duration:H:mm:ss}}",
		"type": "text"
	},

What do I do wrong?

Used this video, with duration of 1:58:56 (exactly the format I’m trying to achieve): https://www.youtube.com/watch?v=YWo3v8uw3WA

What I get in my note is this:

duration 7137
format duration 1:00:7137

Any help appreciated!

Keep the “S” in there so the duration function knows what your units are:

{{schema:@VideoObject:duration|replace:"PT":""|duration:H:mm:ss}}

image

The Boss example:

Thanks dawni, I’m trying, since I understand your answer and agree, but - my notepad++ is still complaining about it (showing orange warning background"). so I think I’m still struggling with the quotationmarks:

	{
		"name": "format duration",
		"value": "{{schema:@VideoObject:duration|replace:"PT":""|duration:H:mm:ss}}"
		}}",
		"type": "text"

A completely other question regarding this matter: what about the Obsidian Help that I showed in my question, is it that bad?

This is the syntax in the json:

			"name": "format duration",
			"value": "{{schema:@VideoObject:duration|replace:\\\"PT\\\":\\\"\\\"|duration:H:mm:ss}}",
			"type": "text"

The syntax from my last comment is how you enter it into the extension interface shown in the image right below it.

Still, the point is: Just remove the part that replaces the “s”.

Sorry, I don’t understand this question:

what about the Obsidian Help that I showed in my question, is it that bad?

Update: To stay as close as possible to what you showed in your original post, I didn’t put quotation marks around the tokens, and it works for the output in question. But the docs use quotation marks—I assume to account for other token and literal combos that would need it—so here’s a version with quotation marks:

In the JSON:

			"value": "{{schema:@VideoObject:duration|replace:\\\"PT\\\":\\\"\\\"|duration:\\\"H:mm:ss\\\"}}",

In the interface:

{{schema:@VideoObject:duration|replace:"PT":""|duration:"H:mm:ss"}}

Thanks again dawni, all is working fine now. Good starting point for optimization of this template to my own needs now. And for further learning as well.

As a 70-year old former IT-er and old-fashioned database developer (pre-SQL), database designer (both on DEC System-2080 with TOPS-20 OS etc. etc.), newbie to Obsidian, I now try to familiarize with markdown, regex, JSON and the rest (possibly have to learn python as well). Works most of the time, but I really appreciate your support.

Best regards, Hans Troost

1 Like