amitbl / blocktube

YouTube™ content blocker
GNU General Public License v3.0
882 stars 62 forks source link

Request: Build a category wise blocking #4

Open gauravgrover95 opened 6 years ago

gauravgrover95 commented 6 years ago

I have completely cut off my Facebook but being a programmer it is essential for me to use YouTube for educational purposes. But YouTube keeps recommending the off-topic very interesting videos which lead to the dark hole of time wastage.

I wish I could simply filter the content by categories such as "educational", "motivational", "entertainments".

Do you think it would be doable?

amitbl commented 6 years ago

It's not possible to remove videos suggestions by topics (YouTube does not provide this info) But it might be possible to block in the video page itself, but still be prone to many errors because this rely on YouTube algorithm to decide which video belong to which category.

However, I do plan to add a Whitelist mode, so you'll be able to set your favourite channels and forget about the rest.

gauravgrover95 commented 6 years ago

That will be great too. Since your code it all JS. Maybe I can help.

How do you plan to do it?

amitbl commented 6 years ago

It shouldn't be too complicated, just switch the rule test from true to false, I will add this in the next version

khonkhortisan commented 5 years ago

In case this information is of any help: Youtube videos have these categories: Film & Animation,Autos & Vehicles,Music,Pets & Animals,Sports,Short Movies,Travel & Events,Gaming,Videoblogging,People & Blogs,Comedy,Entertainment,News & Politics,Howto & Style,Education,Science & Technology,Nonprofits & Activism,Movies,Anime/Animation,Action/Adventure,Classics,Comedy,Documentary,Drama,Family,Foreign,Horror,Sci-Fi/Fantasy,Thriller,Shorts,Shows,Trailers (source: api (set part to snippet and regionCode to us to get the list including channel ids)) These categories appear in the video description, so a video could be blocked using that after loading the page even if by no other way (if the api isn't used, if it doesn't load each video's page in the background just to get the category).

<ytd-metadata-row-container-renderer class="sticky style-scope ytd-video-secondary-info-renderer" slot="sticky">

    <div id="always-shown" class="style-scope ytd-metadata-row-container-renderer"></div>
    <div id="collapsible" class="style-scope ytd-metadata-row-container-renderer"><ytd-metadata-row-renderer class="style-scope ytd-metadata-row-container-renderer">

    <h4 id="title" class="style-scope ytd-metadata-row-renderer">
      <yt-formatted-string class="style-scope ytd-metadata-row-renderer">Categoría</yt-formatted-string>
    </h4>
    <div id="content" class="style-scope ytd-metadata-row-renderer">

        <yt-formatted-string class="content content-line-height-override style-scope ytd-metadata-row-renderer" has-link-only_=""><a class="yt-simple-endpoint style-scope yt-formatted-string" spellcheck="false" href="/channel/UCi-g4cjqGV7jvU8aeSuj0jQ" data-jzz-gui-player="true">Entretenimiento</a></yt-formatted-string>
      <dom-repeat class="style-scope ytd-metadata-row-renderer"><template is="dom-repeat"></template></dom-repeat>
    </div>
  </ytd-metadata-row-renderer></div>
  </ytd-metadata-row-container-renderer>

This gives both the category name Entretenimiento and category channel id UCi-g4cjqGV7jvU8aeSuj0jQ which are different from what the api gives Entertainment and UCBR8-60-B28hp2BmDPdntcQ, probably just because it's a spanish version of the same channel. That's odd… all of them have the same channel id in what the api returned. Might have to track these down manually, or just filter by category name.

khonkhortisan commented 5 years ago
//name of first category in description
window["ytInitialData"].contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.metadataRowContainer.metadataRowContainerRenderer.rows[0].metadataRowRenderer.contents[0].runs[0].text
//channel of first category in description
window["ytInitialData"].contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.metadataRowContainer.metadataRowContainerRenderer.rows[0].metadataRowRenderer.contents[0].runs[0].navigationEndpoint.browseEndpoint.browseId
//channel of first category in description with leading "/channel/"
window["ytInitialData"].contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.metadataRowContainer.metadataRowContainerRenderer.rows[0].metadataRowRenderer.contents[0].runs[0].navigationEndpoint.commandMetadata.webCommandMetadata.url

I see this addon already uses the ytinitialData object, that's a good sign.

bfayers commented 5 years ago

It shouldn't be too complicated, just switch the rule test from true to false, I will add this in the next version

Will this be added any time soon? If not which line(s) could I change locally in order to achieve this, I want to only allow access to a list of channel ids.

In the meantime I have found this to work in the channel name filters:

/^((?!wantedChannelNameHere|anotherWantedChannelHere).)*$/

However, RegExp doesn't work in the channel ID box, but this works in the meantime (assuming unwanted channels don't have the same name as a wanted channel)

ghjb004 commented 3 years ago

Sorry if this is off topic, it relates to whitelisting or blocking by category, which would allow operation with a shorter channel list. I want to ask if we will see performance problems such as long load times if our blocklist gets too long. Short of the ability to block by category or white list, there is no end to the number of channels that are going to end up on my blacklist.