SkyTubeTeam / SkyTube

Copylefted libre / open source YouTube player for Android
GNU General Public License v3.0
2.36k stars 329 forks source link

Extend the video blocker to block YouTube "short" videos #1165

Open maaaat opened 1 year ago

maaaat commented 1 year ago

Is your feature request related to a problem? Please describe. There is a growing number of so-called "short" videos on YouTube. Many channels I subscribe to publish very good content in the form of longer videos (15+ minutes) but also low quality extracts of these videos as shorts. I suppose this is motivated by the need to constantly please the YouTube recommendation algorithm. These shorts are a real annoyance, they fill up the video feed and hide actual content.

Describe the solution you'd like SkyTube already has a video blocking system that can filter videos based on language, number of views, etc. It would be great to be able to filter out the shorts as well. These shorts seem easy to identify: they use a vertical format and always last less than 60 seconds. There might even be specifically identified as shorts in the video metadata.

Describe alternatives you've considered I don't think there is an alternative.

Additional context Issue #1010 suggests using a subject filter to get rid of the shorts. Having white/black lists of hash tags is a nice idea in itself, but I don't think it would work for shorts since the #short tag isn't always present. The duration and aspect ratio would give a better heuristic I think.

navid-zamani commented 1 year ago

Shorts having the #short(s) tag is an official rule by YouTube, for videos that should use the “special” (read: retarded ;) TikTok-like player.
If the tag isn’t there, and the video isn’t both vertical and ≤ minute, it should not be blocked please.

There are three levels of suggestions I could make here:

Normal brain solution:

I specifically would not want it to apply to vertical videos in general. Maybe it would be better to separate it into 3 blockers:

  1. everything with #short(s),
  2. everything up to a minute in length,
  3. everything vertical (although thats pointless on a phone, but it might be of use in certain situations).

Big brain solution:

Maybe all this can be avoided by allowing a more general filter rule system. Which would be easy to code: Just an activity with a text area. Where one enters one filter expression per line. Where the expressions are just a very simple syntax of booleans, variables, comparison operators and regex literals. (I’d implement it by having an interpreter interpret it , that is already available. Say JavaScript.) And where all filterable properties that the API provides (channel, title, description, length, tags, everything that can be auto-generated without having to code it manually) are available as a variable. The text area could be followed be a simple explanation and a list of available properties and their value type. (say: length -- Number -- in seconds)
I imagine this would be doable in a weekend; iff there is an easy to use interpreter available. And if Android isn’t making the smallest thing into a huge ordeal of enterpriseyness yet again. ;)

Galaxy brain solution:

But to be frank, I’m more and more moving to yt-dlp in Termux. So just ditching all this bikeshedding and turning SkyTube into a yt-dlp frontend would probably give a huge amount of added power. (Other sites, loads of config options, automation, no need to code everything yourself, no need for an API key, …)
It would also be a lot of work. … ;)

maaaat commented 1 year ago

Shorts having the #short(s) tag is an official rule by YouTube

Perhaps that is the rule indeed, but in practice the tag isn't always present.

I specifically would not want it to apply to vertical videos in general. Maybe it would be better to separate it into 3 blockers:

  1. everything with #short(s),
  2. everything up to a minute in length,
  3. everything vertical (although thats pointless on a phone, but it might be of use in certain situations).

I meant to have a logical AND between being shorter than a minute and having a vertical format. I don't think that being vertical on its own would be a good heuristic, I wouldn't want that either. So that would be two blockers:

  1. everything with #short(s),
  2. everything up to a minute in length AND with a vertical format.
halvabner commented 1 year ago

+1, i really need this feature

navid-zamani commented 1 year ago

@halvabner: Maybe this helps:

Here's a “workaround” I'm using for now…

I adapted my desktop yt-dlp script to run with Termux, documented it, and translated it to English.

If you only subscribe to channel URLs using /videos/ at the end, you will not get any shorts. And if you want to filter by aspect ratio or size, you can alter the line where it says bestvideo. (yt-dlp has the syntax documented, but it’s a bit complex ;)

I haven’t integrated it with termux-url-opener yet, otherwise sharing URLs from SkyTube to Termux would work with this script.
Nor have I tested it in Termux.
But it’s well-honed to work reliably on the desktop, and should work, if you set up termux-yt-dlp correctly.

#! /bin/bash

#############################################################################
#
# UNTESTED translation for Termux. Please test before using it. And set the settings below.
# NOLICENSE: This script is free for use and modification … by everyone who …
#            neither makes profit off of it,
#            nor employs crime schemes knows as “intellectual property”.
#
#############################################################################
#
# Installation:
#   1. Install https://github.com/rofrol/termux-yt-dlp as per instructions there.
#   2. Put this script in `~/bin/yt` inside Termux.
#   3. Maybe adapt `~/bin/termux-url-opener` to run this script instead.
#
#############################################################################
#
# Syntax:
#   yt [--help] [--best|--interactive|--audio] [--slow|--econonmy] [--subscriptions|--new-subscription <URL>|[additional parameters] <URL> [URL] …]
#
# Just download some stuff (works with almost any URL containing a video or list of videos!):
#  yt $someurl
#
# Add a channel (just the normal videos, no shorts):
#   yt --new-subscription http://www.youtube.com/@SOMECHANNEL/videos/
#
# Download all new videos since adding the channel or since checking the last time:
#   yt --subscriptions
#
# Qualities:
#   --best         Simply the best available quality. No action needed as these are the default settings.
#   --interactive  Ask for every video.
#   --audio        Audio extraction.
#     (ideal)      Ideal size for device (set with `$SCREEN_RESOLUTION`).
#
# Bandwiths:
#  --slow          Slow connection. *Minimize size*. Good for throttled mobile data or to save on metered data. Resulting files will usually be 144p at ~5MB/10min.
#  --economy       Save data without potato quality. Better than 144p, but *not more than 50MB/30min*.
#    (fast)        Normal connection. Uses *3 threads*.
#
# Settings
MY_LANGUAGES='de,en'
BASE_DIR='/sdcard/Download/YouTube'
SCREEN_RESOLUTION='1920x1080+0+0'
#
#############################################################################

# Help mode
if [[ "$1" == "--help" ]]; then cat "$0"; exit; fi

mkdir -p "$BASE_DIR"
cd "$BASE_DIR/"

# Standard parameters
dl=( -P . \
  --console-title \
  --embed-thumbnail --embed-metadata --embed-subs --sub-langs $MY_LANGUAGES,-live_chat \
  --merge-output-format mkv --output '%(channel).64B - %(title).64B.%(id)s.%(ext)s' \
  --download-archive "$BASE_DIR/.download-archive" \
  --match-filter '!is_live' --sponsorblock-mark all \
  --no-skip-unavailable-fragments )
# yt-dlp is too stupid for file names of arbitrary length, otherwise the following would be better: --output '%(channel)s - %(title)s.%(id)s.%(ext)s'
# To actually remove sponsorblock segments (beware, the user-contributed cuts are often very imprecise and bad): --sponsorblock-remove sponsor,selfpromo

# Qualities
if   [[ "$1" == "--best"       ]]; then shift
  # Simply the best available quality. No action needed as these are the default settings.
elif   [[ "$1" == "--interactive"  ]]; then shift
  # Ask for every video.
  dl+=( -f - )
elif [[ "$1" == "--audio"       ]]; then shift
  dl+=( -f 'bestaudio/bestaudio*' -x ) # Audio extraction
else #           --ideal
  resolution="${SCREEN_RESOLUTION:-1920x1080+0+0}" # USE standard HD if no resolution is given.
  width="${resolution/x*/}"; height="${resolution/*x/}"; height="${height/+*/}";
  dl+=( -f 'bestvideo*[height<='"$height"'][width<='"$width"']+bestaudio/best[height<='"$height"'][width<='"$width"']' ) # Ideal size for device
fi

# Bandwidth
if   [[ "$1" == "--slow"     ]]; then shift
  dl+=( -S +size ) # Slow connection. minimize size. Good for throttled mobile data or to save on metered data. Resulting files should be 144p at ~5MB/10min.
elif   [[ "$1" == "--economy"     ]]; then shift
  dl=( -N 3 "${dl[@]}" -f 242+600 ) # Save data without potato quality. Better than 144p, but not more than 50MB/30min.
else #           --fast
  dl=( -N 3 "${dl[@]}" ) # Normal connection. Uses 3 threads. (-N only works, if it is set at the beginning!)
  dl+=( --video-multistreams --audio-multistreams )
fi

# Disable energy saving during the run, or it will cut the connection.
termux-wake-lock

# Command
dl=( yt-dlp "${dl[@]}" )
echo "Command: ${dl[@]@Q}"
if [[ "$1" == '--subscriptions' ]]; then shift
  echo "Checking all subscriptions for updates …"
  echo "  + Additional parameters: --break-on-existing --break-per-input --lazy-playlist $@"
  "${dl[@]}" --break-on-existing --break-per-input --lazy-playlist "$@" $( grep -vE '^#|^$' "$BASE_DIR/.subscriptions" ) # Check all channel URLs for new videos, and download only those.
elif [[ "$1" == '--new-subscription' ]]; then shift # Syntax: --new-subscription <URL>
  echo "$1" >> "$BASE_DIR/.subscriptions"
  echo "Subscription »$1« added to the list!"
  echo "Downloading new channel metadata …"
  echo "  + Additional parameters: --simulate --force-write-archive --skip-download --flat-playlist"
  dl+=( --simulate --force-write-archive --skip-download --flat-playlist ) # Quickly enter all videos of the channel into the archive. Marks all videos as already downloadad for `--subscriptions`!
  "${dl[@]}" "$1"
else
  echo "URLs  : $@"
  "${dl[@]}" "$@" # Download URLs in Parameters.
fi

# Re-enable energy saving
termux-wake-unlock