Skip to content

Instantly share code, notes, and snippets.

@brettpetch
Last active March 28, 2023 20:18
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brettpetch/2f3147eaff75294003261df9dfd0208a to your computer and use it in GitHub Desktop.
Save brettpetch/2f3147eaff75294003261df9dfd0208a to your computer and use it in GitHub Desktop.
#!/bin/bash
autobrr_config=$HOME/.config/autobrr/autobrr.db
declare -a filters=(race-TV race-TV4K race-TVDV race-Movies race-Movies4K race-MoviesDV race-BluRay race-BluRay4K race-BluRayDV)
bu_keep_days=3 #number of days to keep
db_path=$HOME/.config/autobrr/
# Install dependency for scripts
type curl &>/dev/null || {
sudo apt-get update > /dev/null 2>&1
sudo apt-get install -y curl > /dev/null 2>&1
}
type sqlite3 &>/dev/null || {
sudo apt-get update > /dev/null 2>&1
sudo apt-get install -y sqlite3 > /dev/null 2>&1
}
# Grab upcoming blurays
bluray=$(
curl -sL "https://sudoer.dev/bluray" || {
echo "Failed to run BluRay injection."
exit 1
}
)
# Grab upcoming movies
movies=$(
curl -sL "https://sudoer.dev/movies" || {
echo "Failed to run Streaming Movies injection."
exit 2
}
)
shows=$(
curl -sL "https://sudoer.dev/tv" || {
echo "Failed to run TV injection."
exit 3
}
)
# Grab 7 days worth of upcoming TV shows. If they have reach 50% rating on trakt it moves there.
shows_anticipated=$(
curl -sL "https://sudoer.dev/anticipated" || {
echo "Failed to run Anticipated injection."
exit 4
}
)
sqlite3 ${autobrr_config} ".backup ${autobrr_config}.$(date +"%Y_%m_%d_%I_%M_%p").bak" || {
echo "failed to backup db"
exit 6
}
mov='.*mov*'
blu='.*blu*'
tv='.*tv*'
tvant='.*ant*'
group='.*group*'
#4k='.*4k*'
#dv='.*dv*'
for i in ${filters[@]}; do
if [[ ${i,,} =~ ${tvant} ]]; then
sqlite3 ${autobrr_config} <<EOS
update filter set match_releases = "${shows_anticipated}" where name = "${i}";
EOS
elif [[ ${i,,} =~ ${blu} ]]; then
sqlite3 ${autobrr_config} <<EOS
update filter set match_releases = "${bluray}" where name = "${i}";
EOS
elif [[ ${i,,} =~ ${mov} ]]; then
sqlite3 ${autobrr_config} <<EOB
update filter set match_releases = "${movies}" where name = "${i}";
EOB
elif [[ ${i,,} =~ ${group} ]]; then
sqlite3 ${autobrr_config} <<EOC
update filter set match_release_groups = "${release_groups}" where name = "${i}";
EOC
elif [[ ${i,,} =~ ${tv} ]]; then
sqlite3 ${autobrr_config} <<EOD
update filter set match_releases = "${shows}" where name = "${i}";
EOD
else
echo "${i} did not match either movie or tv."
fi
done
find $db_path -name "autobrr.db.20??_??_??_??_??_??.bak" -mtime +$bu_keep_days -type f -delete
@brettpetch
Copy link
Author

brettpetch commented Feb 8, 2022

Regbrr

This is a script that will take input for filters, then match them against a set of pre-defined strings to match against. If it finds a match in the filter name, it will update the respective filter. This was rewritten this way because some users have 4K/4K DV filters and want them to match without introducing additional variables. By using a bash array, as declared on line 3, we are able to specify a number of filters and loop through them.

Setting up this script is as simple as

  1. Creating the initial filters in autobrr (here we use the examples of race-TV race-TV4K race-TVDV race-Movies race-Movies4K race-MoviesDV race-BluRay race-BluRay4K race-BluRayDV).
  2. Running the script, then setting up as a cronjob (every x hours/days/weeks). Anticipated releases are fully changed every 7 days.
  3. Setting the actions for each filter.

Note that this script will backup the database prior to running. To clear out the db backups, you can do rm -f ~/.config/autobrr/*.bak*

There are no warranties or guarantees when running this script. It is your responsibility to ensure that all domains resolve correctly and that your db doesn't get f*cked up.

Do not contact me for support. This is not officially supported by the app dev in any kind of capacity. You should understand how this works if you so choose to use it.

@Yankees4life
Copy link

Hello

Do you got an api version of this?

Cheers

@brettpetch
Copy link
Author

brettpetch commented Sep 16, 2022 via email

@Chuchodavids
Copy link

This link is not working: https://gl0ry.us/groups
How can that link be replaced?

@brettpetch
Copy link
Author

Hi,

no plans on replacement atm.

@Chuchodavids
Copy link

Hi,

no plans on replacement atm.

Can you give me a clue of what was on that file, So I could recreate it.

@s0up4200
Copy link

Hi,
no plans on replacement atm.

Can you give me a clue of what was on that file, So I could recreate it.

It was a comma separated list of release groups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment