RE: DTube 0.8: The grand upgrade is finally here. DTV, DTalk, VIP system, etc

You are viewing a single comment's thread from:

DTube 0.8: The grand upgrade is finally here. DTV, DTalk, VIP system, etc

in dtube •  6 years ago 

Such hacks as this shouldn't be necessary

cd ~/autopin
cat auto-pin.sh 
#!/bin/bash

ACCOUNT="magali"

mkdir pinned 2> /dev/null || true
mkdir 404 2> /dev/null || true

for x in pinned/*; do
    if [ -f "$x" ]; then rm "$x"; fi
done

/usr/local/bin/ipfs pin ls | cut -f 1 -d ' ' | while read hash; do
    touch pinned/$hash
done

curl -s --data '{"jsonrpc":"2.0", "method":"follow_api.get_blog", "params":{"account":"'$ACCOUNT'","start_entry_id":0,"limit":500}, "id":1}' https://api.steemit.com \
    | sed 's|{"comment":|\n\n{"comment":|g'    \
    | grep 'root_author":"'$ACCOUNT'' \
    | sed 's/"Qm/\nQm/g' \
    | grep '^Qm' \
    | cut -c 1-46 \
    | sort \
    | uniq \
    | shuf \
    | while read hash; do
        if [ -f pinned/$hash ]; then
            continue;
        fi
        echo "Trying: $hash"
        curl -sS --max-time 3600 --connect-timeout 2 -I "http://127.0.0.1:8081/ipfs/$hash" > /dev/null 2>&1  &
        curl -sS --max-time 120 --connect-timeout 2 -I "http://ipfs.io/ipfs/$hash" > /dev/null 2>&1 &
        curl -sS --max-time 120 --connect-timeout 2 -I "http://cloudflare-ipfs.com/ipfs/$hash" > /dev/null 2>&1 &
        curl -sS --max-time 2 --connect-timeout 2 -I "http://127.0.0.1:8081/ipfs/$hash" > /dev/null 2>&1 
        if [ $? = 0 ]; then
            echo "Pinning: ${hash}"
            /usr/local/bin/ipfs pin add "/ipfs/$hash" 
            if [ $? = 0 ]; then
                touch pinned/${hash}
                continue
            fi
        else
            if [ -f 404/$hash ]; then
                continue
            fi
            rm "$hash" 2> /dev/null
            wget -t 1 -T 10 "https://snap1.d.tube/ipfs/$hash" > /dev/null 2>&1
            status=$?
            if [ $status != 0 ]; then
                wget -t 1 -T 30 "https://video.dtube.top/ipfs/$hash" > /dev/null 2>&1
                status=$?
                if [ $status = 8 ]; then
                    touch 404/$hash
                    continue
                fi
            else
                ipfs add "$hash"
                rm "$hash"
                sleep 1
            fi
        fi
    done
exit 0
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Okay, this looks good. In the end, the hash is always the same, so your approach is pretty good. If it's necessary, everybody should decide for himself. But this way you always have the assurance that your video remains accessible.