YouTube no ads

Moderator: Forum moderators

Post Reply
jrb
Posts: 177
Joined: Sat Oct 24, 2020 5:47 pm
Has thanked: 5 times
Been thanked: 62 times

YouTube no ads

Post by jrb »

YTnoad-01.pet
(3.14 KiB) Downloaded 48 times

A while ago I downloaded yt-dnd*, a nice little drag and drop (dnd) script to play youtube videos in embedded mode (no ads). I used it as a model to create a dnd script to open text URL's (not links), but I ended up with two icons over the top of my browser (clutter). I wondered if I could copy URL's to the clipboard and launch them from there. Turned out it was pretty simple so, using some of the script from yt-dnd, here it is.

If you copy any valid URL just click on the YT icon in the tray and it will open it in your defaultbrowser. This could be highlight and copy or right click in your browser and "Copy Link Location" or any other way you can get a URL onto your clipboard. If the URL happens to be a youtube video it will open it in embedded mode, meaning no ads.

Tried on Buster, Fossa, Tahr, and Quirky7. Requires yad and a defaultbrowser.

*Sorry :oops: , I can't find it in the Puppy Forums and its unsigned. If its your script let me know and I'll give you full credit.
**Mystery solved, the script that I copied was fredx181's version of MochiMoppel's Youtube without ads both great coders. Thanks to both of you and my apologies for forgetting where I downloaded the script.

Attachments
YTnoad3.jpg
YTnoad3.jpg (66.81 KiB) Viewed 685 times
Last edited by jrb on Sat Mar 27, 2021 2:47 pm, edited 1 time in total.
User avatar
amethyst
Posts: 2361
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 55 times
Been thanked: 479 times

Re: YouTube no ads

Post by amethyst »

Thanks, jrb. This works BUT unfortunately using the embedded mode this way is very inadequate because so many videos are not playing (nothing wrong with the script it's just the limitation of the embedded mode). I play all my videos via sites like DuckDuckGo, Bing, Yahoo. You search for the video under the video tab which will then display your search results. Clicking on the video will play embedded on the site, no ads and no other crap of the youtube site (fullscreen mode is available). In my experience all videos play unless there is a message that the video can only be played on the youtube site itself due to restrictions.

jrb
Posts: 177
Joined: Sat Oct 24, 2020 5:47 pm
Has thanked: 5 times
Been thanked: 62 times

Re: YouTube no ads

Post by jrb »

amethyst wrote: Thu Mar 25, 2021 7:12 pm

In my experience all videos play unless there is a message that the video can only be played on the youtube site itself due to restrictions.

I've run into one video which gave me this message with YTnoads, all others have played. Perhaps you can post links to videos which do not play in YTnoads?

User avatar
amethyst
Posts: 2361
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 55 times
Been thanked: 479 times

Re: YouTube no ads

Post by amethyst »

jrb wrote: Thu Mar 25, 2021 8:21 pm
amethyst wrote: Thu Mar 25, 2021 7:12 pm

In my experience all videos play unless there is a message that the video can only be played on the youtube site itself due to restrictions.

I've run into one video which gave me this message with YTnoads, all others have played. Perhaps you can post links to videos which do not play in YTnoads?

Many, many not playing for me. Try the videos on this page for starters: https://www.youtube.com/channel/UC-9wY4 ... hKw/videos

jrb
Posts: 177
Joined: Sat Oct 24, 2020 5:47 pm
Has thanked: 5 times
Been thanked: 62 times

Re: YouTube no ads

Post by jrb »

amethyst wrote: Fri Mar 26, 2021 12:48 am

Try the videos on this page for starters: https://www.youtube.com/channel/UC-9wY4 ... hKw/videos

I see what you mean. Looks like the music industry has a protection agreement with YouTube.

Oh well, it serves my purposes, perhaps some others as well.

Cheers, J

User avatar
amethyst
Posts: 2361
Joined: Tue Dec 22, 2020 6:35 am
Has thanked: 55 times
Been thanked: 479 times

Re: YouTube no ads

Post by amethyst »

jrb wrote: Fri Mar 26, 2021 1:26 am
amethyst wrote: Fri Mar 26, 2021 12:48 am

Try the videos on this page for starters: https://www.youtube.com/channel/UC-9wY4 ... hKw/videos

I see what you mean. Looks like the music industry has a protection agreement with YouTube.

Oh well, it serves my purposes, perhaps some others as well.

Cheers, J

They play (well, almost all) with the method I described in my post and of course on youtube itself. It's just a limitation of the embedded mode.

User avatar
MochiMoppel
Posts: 1154
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 19 times
Been thanked: 381 times

Re: YouTube no ads

Post by MochiMoppel »

jrb wrote:

If you copy any valid URL just click on the YT icon in the tray and it will open it in your defaultbrowser.

And so will any invalid URL :shock:
Your script looks very much like my script I posted in View Youtube without ads. Did you use it as your template?
My script:

Code: Select all

BROWSER=defaultbrowser
YTURL=$(xclip -o -sel clip) || YTURL=$(xsel -b)
(($?)) && exec Xdialog -msg "xclip or xsel not installed" x
case $YTURL in
*youtube.com*v%3D*) VIDID=${YTURL#*v%3D};;
  *youtube.com*v=*) VIDID=${YTURL#*v=};;
  *youtu.be*      ) VIDID=${YTURL#*.be/};;
  *               ) exec Xdialog -msg "Not a recognized YouTube URL:\n\n${YTURL::50}" x;;
esac
VIDID=${VIDID::11}
exec $BROWSER "https://www.youtube.com/embed/$VIDID?autoplay=1"

Your script:

Code: Select all

BROWSER=defaultbrowser
xclip -o > /tmp/YTnoad.txt
URL=`cat /tmp/YTnoad.txt`
echo "$URL"
YTURL=`echo "$URL" | grep "youtube"`
if [[ ! $YTURL == "" ]]
  then
    case "$YTURL" in
    *youtube.com*v%3D*) VIDID=${URL#*v%3D};;
      *youtube.com*v=*) VIDID=${URL#*v=};;
      *youtu.be*      ) VIDID=${URL#*.be/};;
      *               ) $BROWSER "$URL"; exit;;
    esac
    VIDID=${VIDID::11}
    $BROWSER "https://www.youtube.com/embed/$VIDID?autoplay=1"
    else
    $BROWSER "$URL"
fi

Your code contains a couple of inconsistencies, does not read the clipboard, does not catch the valid youtube URL youtu.be and accepts just anything in the current selection buffer, be it URL or not, and sends it to the browser. I also don't understand the need for the /tmp/YTnoad.txt detour.

jrb
Posts: 177
Joined: Sat Oct 24, 2020 5:47 pm
Has thanked: 5 times
Been thanked: 62 times

Re: YouTube no ads

Post by jrb »

MochiMoppel wrote: Sat Mar 27, 2021 3:23 am

And so will any invalid URL :shock:
Your script looks very much like my script I posted in View Youtube without ads. Did you use it as your template?

HaHa! Looks like I was having a "senior moment." :oops:

I actually used fredx181's version of your script as the template, but as I said in the 1st post I couldn't remember where I had downloaded it and a forum search didn't turn it up. If I may make a suggestion, you write good code 8-) , you should include a rem with your name at the top.

As for invalid symlinks opening in my script, yes but closing an extra tab in my browser is a small price to pay for being able to open URL's which are given as text instead of hyperlinks without the need to copy and paste. I am especially irritated by pkgs.org which gives file download addresses as text.

I will amend my 1st post to give you full credit. I have been scaling back my Puppy participation, I think this may be a sign its time to retire.

Cheers, J

User avatar
MochiMoppel
Posts: 1154
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 19 times
Been thanked: 381 times

Re: YouTube no ads

Post by MochiMoppel »

jrb wrote:

As for invalid symlinks opening in my script, yes but closing an extra tab in my browser is a small price to pay for being able to open URL's which are given as text instead of hyperlinks without the need to copy and paste

Well, if you fix your code you wouldn't have to pay a "small price".
Would give you the satisfaction to have created a script that "just works" .... maybe :lol:

Post Reply

Return to “Browsers and Internet”