Privacy-focused youtube workflow

@dalto @_Six
Just one question regarding the script: can it be modified in a way the it downloads the video to the present working directory, wherever that may be at the time of running the script?

Change this line:

DL_DIR="$HOME/Downloads/yt"

To:

DL_DIR=$PWD

But that may cause problems if you run it from a hotkey depending on what you working directory is considered at that time.

2 Likes

Thanks! I’ll try that later. It is working fine now and I don’t want to break it or anything.

You were right, from the hotkey, it didn’t work. It does of course when run from terminal in the $PWD.

Just to back up a little.

This commemorates about a week of my IP block from freetube. (But, of course, not youtube, ironically).

I’m doing the tedious cut-and-paste-Freetube-web-adress-to-song into mpv in terminal, then wait for MPV to launch.
This sucks.

Youtube bans my IP if I play in Freetube.
Youtube does not ban my IP if I play song in Youtube (of course).
Youtube does not ban my IP using terminal to launch MPV.
Can they see it?
Advantages to mpv? Don’t YT cookies also come into my PC in this methid? Isn’t my IP also visible in the MPV Method?

My head hurts :slight_smile:

1 Like

From what I gather, no. Not if you want to see restricted content etc which requires to be signed in. Then you would need to import a cookie into mpv. Don’t ask me how :sweat_smile:

I guess it is.

1 Like

The issue appears to have been resolved in a recent commit, probably as a result of this commit, bumping the youtubei.js version.

For me, things at the moment appear to be working again in freetube-git.

3 Likes

I have a rather large FreeTube playlist that helps me focus when doing development. I was inspired by @dalto’s use of yt-dlp and decided I’d try to batch download this large playlist with a single yt-dlp command.

In FreeTube, I exported my playlist, which produces a .db file (json). To convert that to a simple text file containing a list of the YouTube URL’s that yt-dlp can use to batch download, I ended up producing a few working options:

Option 1. The more elegant (json aware) Python option:

# Converts any FreeTube DB (JSON) in the current folder to a simple list of YouTube URL's.
import json,glob

for db in glob.glob("*.db"):
    with open(db, 'r') as file:
        data = json.load(file)

    with open(db+".txt", "w") as file:
        for i in data['videos']:
            file.write("https://youtu.be/" + i['videoId'] + "\n")

Option 2. A fairly crude non-json aware shell script, that also does the job:

#!/bin/bash

# Converts any FreeTube DB (JSON) in the current folder to a simple list of YouTube URL's.
for i in *.db; do
    [ -f "$i" ] || break
    sed 's/videoId/\nvideoId/g' ${i} | grep videoId | awk -F: '{ print $2 }' | awk -F, '{ print $1 }' | tr -d '"' | awk '{ print "https://youtu.be/" $0 }' > ${i}.txt
done

Option 3. Convert with a single command (change input/output filename to suit):

sed 's/videoId/\nvideoId/g'  myplaylist.db | grep videoId | awk -F: '{ print $2 }' | awk -F, '{ print $1 }' | tr -d '"' | awk '{ print "https://youtu.be/" $0 }' > myplaylist.txt

Then I use this command on the .txt file that produced, to batch download the highest quality audio only (change the file name of course):

yt-dlp -f ba -a "freetube-myplaylist.db.txt"
6 Likes

I just did a small modification to @dalto’s script to just steram the video from the URL in the clipboard in MPV with a hotkey. As I don’t always want to download the file, this works great for me. I feel that I almost can do away with Freetube.

2 Likes

Thanks for this post, very useful since I was recently thinking of downloading my playlists in to separate files (One of many playlists being almost 700 videos). YouTube would have been the only Google service I would have to interact with otherwise.

2 Likes