#!/bin/bash # ============================================================================== # FUNCTIONS - START # ============================================================================== VERSION='1.1.12' BASEDIR="${2-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}" run_rebrand() { printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Rebrand...' '\e[m' mv -T yt_dlp hypervideo_dl mv bin/yt-dlp bin/hypervideo find . -type f \( \ -iname "*" \ ! -iname "build.sh" \ ! -iname ".travis.yml" \ ! -iname ".gitlab-ci.yml" \ ! -path "./.git*" \) \ -exec grep -rIl 'yt_dlp' {} + -exec sed -i 's|yt_dlp|hypervideo_dl|g' {} \; find . -name "tox.ini" -type f -exec sed -i 's|yt-dlp|hypervideo|g' {} \; find . -name "setup.cfg" -type f -exec sed -i 's|yt-dlp|hypervideo|g' {} \; find . -name "Makefile" -type f -exec sed -i 's|yt-dlp|hypervideo|g' {} \; find . -name "*.py" -type f -exec sed -i 's|yt-dlp|hypervideo|g' {} \; find . -name "*.in" -type f -exec sed -i 's|yt-dlp|hypervideo|g' {} \; find docs -type f -exec sed -i 's|yt-dlp|hypervideo|g' {} \; # fixes URLs find . -name "*.py" -type f -exec sed -i 's|hypervideo+test+video|yt-dlp+test+video|g' {} \; find . -name "*.py" -type f -exec sed -i 's|https://github.com/ytdl-org/hypervideo/|https://github.com/ytdl-org/yt-dlp/|g' {} \; find . -name "*.py" -type f -exec sed -i 's|https://github.com/rg3/hypervideo/issues/|https://github.com/rg3/yt-dlp/issues/|g' {} \; find . -name "*.py" -type f -exec sed -i 's|http://hypervideo.bandcamp.com/|http://yt-dlp.bandcamp.com/|g' {} \; find . -name "*.py" -type f -exec sed -i 's|http://yt-dlp.bandcamp.com/track/hypervideo-test-song|http://yt-dlp.bandcamp.com/track/yt-dlp-test-song|g' {} \; find . -name "*.py" -type f -exec sed -i 's|https://www.dropbox.com/s/nelirfsxnmcfbfh/hypervideo|https://www.dropbox.com/s/nelirfsxnmcfbfh/yt-dlp|g' {} \; find . -name "*.py" -type f -exec sed -i 's|http://8tracks.com/ytdl/hypervideo-test-tracks-a|http://8tracks.com/ytdl/yt-dlp-test-tracks-a|g' {} \; find . -name "*.py" -type f -exec sed -i 's|http://phihag.de/2014/hypervideo/|http://phihag.de/2014/yt-dlp/|g' {} \; find . -name "*.py" -type f -exec sed -i 's|https://hypervideo-demo.neocities.org/|https://yt-dlp-demo.neocities.org/|g' {} \; find . -name "*.py" -type f -exec sed -i 's|https://travis-ci.org/ytdl-org/hypervideo/|https://travis-ci.org/ytdl-org/yt-dlp/|g' {} \; find . -name "*.py" -type f -exec sed -i 's|https://soundcloud.com/jaimemf/hypervideo-test|https://soundcloud.com/jaimemf/yt-dlp-test|g' {} \; find . -name "*.py" -type f -exec sed -i 's|http://streamcloud.eu/skp9j99s4bpz/hypervideo_test_video|http://streamcloud.eu/skp9j99s4bpz/yt_dlp_test_video|g' {} \; find . -type f \( \ -iname "*" \ ! -iname "build.sh" \ ! -iname ".travis.yml" \ ! -iname ".gitlab-ci.yml" \ ! -path "./.git*" \) \ -exec grep -rIl 'YT-DLP' {} + -exec sed -i 's|YT-DLP|HYPERVIDEO|g' {} \; # Set current version sed -i "s|__version.*|__version__ = '${VERSION}'|" hypervideo_dl/version.py # Set license sed -i "s|UNLICENSE|CC0-1.0|" docs/conf.py } run_clean() { printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Clean tempfiles...' '\e[m' rm -rf -- hypervideo.1.temp.md hypervideo.1 hypervideo.bash-completion README.txt MANIFEST build/ dist/ .coverage cover/ hypervideo.tar.gz hypervideo_dl/extractor/lazy_extractors.py *.dump *.part* *.ytdl *.info.json *.mp4 *.m4a *.flv *.mp3 *.avi *.mkv *.webm *.3gp *.wav *.ape *.swf *.jpg *.png CONTRIBUTING.md.tmp hypervideo hypervideo.exe find . -name "*.pyc" -delete find . -name "*.class" -delete } run_make() { printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Making hypervideo...' '\e[m' make hypervideo.tar.gz } run_copy() { printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Genering build...' '\e[m' install -d -m755 build mv hypervideo.tar.gz "./build/hypervideo.tar.gz" cd build && tar xzf hypervideo.tar.gz && mv hypervideo "hypervideo-${VERSION}" && tar -czvf "hypervideo-${VERSION}.tar.gz" "hypervideo-${VERSION}" && rm -rf "hypervideo-${VERSION}" hypervideo.tar.gz cd "$BASEDIR" || return printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Tarball in build/ directory' '\e[m' } # Restore directory, compatibility reasons run_reset() { printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Restore compatibility...' '\e[m' mv -T hypervideo_dl yt_dlp mv bin/hypervideo bin/yt-dlp rm -v hypervideo printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Please execute: "git checkout ." for complete restore' '\e[m' } # ============================================================================== # EXECUTION - START # ============================================================================== run_rebrand "$@" && run_clean "$@" run_make "$@" run_copy "$@" && run_reset "$@"