DT youtube save problem - pesky link spam spoiling experience

This concerns pesky interactions between utube “consent” and DT.

So I’m watching a youtube link (iPad) that i want to save in DT…

But when I go to save (via the share option below the video, as above pic) the title and link prefix is getting modified by utube with

"Before you continue to YouTube"
(despite me trying to “consent” with utube)

So the result of the save is no title, and a pesky prefix that corrupts my link :frowning:

So please DT, can this google/utube consent spam be filtered out??

I note maybe it can, as this problem does not appear with other applications eg Bear… Yes, the title is spammed, but it at least takes you to the right utube video

So in summary:

(1) Can DT remove that pesky consent prefix like other apps (eg Bear)

Going further (icing on the cake)

**(2) Can DT have a built in youtube Ad block ? These Ads persist if I open the link internally within DT…

( In case its useful to others, a partial solution to (2)…

So IF I’m lucky not to have that pesky consent spam (see (1) above ), I open the link in Safari externally which then uses the adblock I got (“Dynamo” app) for player peace. )

As that first bit of the link is presumably always the same, you could easily remove it with a smart rule calling a very simple script.

Edit: and this also does not happen (to me) using the YouTube app rather than Safari to generate the link.

1 Like

This is untested, because I don’t have any files handy to test it on; it will only work if the first section of the URL is always https://consent.youtube.com/ml?continue= which I assume will be the case; otherwise you’d need to adjust the condition in the rule. The script will cut the URL at the first = so would work with any URL which needed to be cut at that point.

This is the embedded script:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set theURL to URL of theRecord
			set thePos to offset of "=" in theURL
			set thePos to thePos + 1
			set theURL to texts thePos thru -1 of theURL
			set URL of theRecord to theURL
		end repeat
	end tell
end performSmartRule

Once you have changed the URL of one of your bookmarks, you could try running the script called _Set Name To Title Of Web Page from the Script/Rename menu in DT. If that changes the title of your bookmark in the fashion you want, that script could easily be integrated into the little script I wrote, meaning you would get what you wanted with one simple smart rule :slight_smile:

If that does work, then this should do the whole trick:

-- includes sections from C. Grunenberg: Set name to title of web page
-- those sections Copyright C. Grunenberg

on performSmartRule(theRecords)
	tell application id "DNtp"
		try
			repeat with theRecord in theRecords
				set theURL to URL of theRecord
				set thePos to offset of "=" in theURL
				set thePos to thePos + 1
				set theURL to texts thePos thru -1 of theURL
				set URL of theRecord to theURL
				-- © C. Grunenberg
				set this_source to download markup from theURL
				if this_source is not missing value then
					set this_title to get title of this_source
					if this_title is not missing value and this_title is not "" then set the name of theRecord to this_title
				end if
				-- end
			end repeat
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		end try
	end tell
end performSmartRule

@cgrunenberg Criss, I’m assuming it is ok to take parts of your scripts and integrate them in new ones, so long as the source is recognised?

All the scripts which I posted or ship together with DEVONthink 3.x can of course be reused & modified.

1 Like

Wow, pretty cool.

In my case, I don’t see those URLs when sharing, but the name is always “Before you continue to YouTube” for any bookmark.

So I tried making a smart rule and copied the code from _Set Name To Title Of Web Page.scpt into it, but it doesn’t work. I have no clue about scripting, could you tell me what I need to paste into the embedded script?

Thank you

Primarily you should check to see whether if you select a file and then choose the Set Name To Title Of Web Page script from the menu your file is correctly renamed. If it is, I’ll show you how to integrate that script into a smart rule.

Yes, that works manually. Thank you

Do you want in a smart rule? Then I’ll edit it later on

Does it make a difference:

  • whether you’re signed in to YouTube or not
  • whether you’re using the YouTube app or not

Just thinking aloud, really

Yes, I wanted to use it in the smart rule as shown below, but pasting the script contents didn’t work.

Not for me. It seems that recent YouTube changes completely ruined sharing YouTube URLs. This applies to most apps I tried. Apple Notes, Messages, …
There are no previews possible any longer in Messages for instance.
In Notes, it looks like this:

Given that these apps don’t have anything to do with your login details / cookies from the browser or the YouTube app, my guess is that this can only be fixed by YouTube.

On iPad, doing Share, Copy link and then pasting to DT seems to work

I’ll edit it for you later on; basically it just needs changing from selection to rule - I’m just not at my Mac

1 Like

This should work (tested once on a URL with an appropriate smart rule, worked):

-- Set name to title of web page
-- Created by Christian Grunenberg Mon Apr 26 2004.
-- Copyright (c) 2004-2019. All rights reserved.
-- adapted for Smart Rule by Blanc with kind permission
on performSmartRule(this_selection)
	tell application id "DNtp"
		try
			set this_count to count of this_selection
			if this_count > 0 then
				show progress indicator "Renaming" steps this_count
				repeat with this_item in this_selection
					set this_type to the type of this_item
					set this_source to missing value
					step progress indicator (name of this_item) as string
					if this_type is equal to html or this_type is equal to webarchive then
						set this_source to source of this_item
					else if this_type is equal to bookmark then
						set this_URL to the URL of this_item
						if this_URL is not "" then set this_source to download markup from this_URL
					end if
					if this_source is not missing value then
						set this_title to get title of this_source
						if this_title is not missing value and this_title is not "" then set the name of this_item to this_title
					end if
				end repeat
				hide progress indicator
			end if
		on error error_message number error_number
			hide progress indicator
			if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		end try
	end tell
end performSmartRule

Pls post back whether the rule runs as it should. Cheers.

1 Like

That works perfectly. Thank you Blanc! :smiley:

1 Like

You’re most welcome - very pleasing :slight_smile:

1 Like

Hi Blanc,

Thanks for looking into this…I wanted to add I’m still unable to solve the problem with youtube bookmarks coming from my iPad…

Here’s the “info” original utube bookmark as it displays on the iPad, and I can see the part of the url I want after the consent prefix (below)…

However after it now appears as a synced file on my Mac, “Get Info” shows the prefix only remains! (see below)

I can’t fathom how syncing from iPad to Mac has lost the url?

Sadly, because of the truncated url, I now can’t use the excellent script :frowning:

It’s the full URL but DEVONthink’s Inspector displays it in a way that one can think it’s cut. Select the URL field and move down via mouse or arrow key to see the whole URL.

@cgrunenberg Seeing both Inspectors side by side in @carl99’s post I wonder why DEVONthink wraps the URL and DEVONthink To Go doesn’t. Is this a macOS limitation?

In the Info inspector the URL field is automatically resized but in the Info popover that’s not the case but the URL field should probably be truncated not wrapped. Changed.

2 Likes

CAN ANYONE SPOT THE issue with the “rename utube” script - it fails for me (Blanc?)

…basically nothing happens except detection of the ‘web internet location’ files, leaving behind the pesky url spam I still can’t get rid of.

First thanks to pete31 - I can see the inspector url now.

Also, in connection with the script “rename utube” I can see the url easily in DT list form (below)

Now back to the issue at hand, here’s the full context in case anyone can solve: :crossed_fingers:

1. Here is where I apply “rename utube” :

2. Here are details of my script settings (the script although not fully shown, is a copy paste from “Blanc” 4 days ago )

Much appreciated if anyone can find why “rename utube” is not stripping the url spam, as up against a saving utube videos wall, with DT now.