mirror of
https://github.com/NohamR/Ratio.py.git
synced 2025-05-24 00:38:57 +00:00
automatic TR version update in all code
This commit is contained in:
parent
ffe299edda
commit
a0ca0e5544
50
update_transmission_version.sh
Normal file
50
update_transmission_version.sh
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Function to get the latest Transmission version from GitHub
|
||||||
|
get_latest_transmission_version() {
|
||||||
|
curl -s GET "https://api.github.com/repos/transmission/transmission/tags?per_page=1" | awk -F'[:,"]' '/"name"/{print $5}'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get the current Transmission version from README.md
|
||||||
|
get_current_transmission_version() {
|
||||||
|
grep -i transmission README.md | cut -d ' ' -f 3
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to format version number to four digits
|
||||||
|
format_version_number() {
|
||||||
|
version=$1
|
||||||
|
formatted_version=$(echo $version | tr -d '.') # Remove dots
|
||||||
|
printf "%04d" $formatted_version # Ensure it has 4 digits
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if update is needed
|
||||||
|
latest_version=$(get_latest_transmission_version)
|
||||||
|
current_version=$(get_current_transmission_version)
|
||||||
|
|
||||||
|
# Formatting versions for class names
|
||||||
|
current_class_version=$(echo $current_version | tr -d '.')
|
||||||
|
latest_class_version=$(echo $latest_version | tr -d '.')
|
||||||
|
|
||||||
|
# Formatting peer IDs
|
||||||
|
current_peer_id=$(format_version_number $current_class_version)
|
||||||
|
latest_peer_id=$(format_version_number $latest_class_version)
|
||||||
|
|
||||||
|
if [ "$latest_version" != "$current_version" ]; then
|
||||||
|
echo "An update is available. Current version: $current_version, Latest version: $latest_version"
|
||||||
|
|
||||||
|
# Update README.md
|
||||||
|
sed -i "s/Transmission $current_version/Transmission $latest_version/" README.md
|
||||||
|
|
||||||
|
# Update process_torrent.py
|
||||||
|
sed -i "s/Transmission$current_class_version/Transmission$latest_class_version/" code/process_torrent.py
|
||||||
|
|
||||||
|
# Update torrentclientfactory.py
|
||||||
|
sed -i "s/Transmission$current_class_version/Transmission$latest_class_version/" code/torrentclientfactory.py
|
||||||
|
sed -i "s/Transmission[\/\ ]$current_version/Transmission\/$latest_version/" code/torrentclientfactory.py
|
||||||
|
sed -i "s/-TR${current_peer_id}-/-TR${latest_peer_id}-/" code/torrentclientfactory.py
|
||||||
|
|
||||||
|
echo "Update completed."
|
||||||
|
else
|
||||||
|
echo "Current version is already up to date."
|
||||||
|
fi
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user