Skip to content

Instantly share code, notes, and snippets.

@meinside
Last active May 3, 2022 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meinside/1293653a732c9f034a78 to your computer and use it in GitHub Desktop.
Save meinside/1293653a732c9f034a78 to your computer and use it in GitHub Desktop.
send push through pushbullet on transmission(torrent) completion.
/*
Send a message on Transmission(torrent) completion:
https://trac.transmissionbt.com/wiki/Scripts
* Created on : 2015.07.07.
* Last update: 2015.07.16.
* by meinside@duck.com
* Usage:
1. install pushbullet-go-helper (https://github.com/meinside/pushbullet-go-helper)
2. build this file ($ go build pushbullet-transmission.go)
3. put your ACCESS_TOKEN in the .pushbullet.token file (in the same directory where this executable file resides)
4. edit transmission configuration file:
$ sudo service transmission-daemon stop
$ sudo vi /etc/transmission-daemon/settings.json
# change following values:
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/path/to/pushbullet-transmission",
$ sudo service transmission-daemon start
*/
package main
import (
"fmt"
"github.com/meinside/pushbullet-go-helper"
"os"
"strings"
)
const (
VERSION = "TR_APP_VERSION"
TIME = "TR_TIME_LOCALTIME"
DIR = "TR_TORRENT_DIR"
HASH = "TR_TORRENT_HASH"
ID = "TR_TORRENT_ID"
NAME = "TR_TORRENT_NAME"
)
func main() {
//version := strings.TrimSpace(os.Getenv(VERSION))
time := strings.TrimSpace(os.Getenv(TIME))
dir := strings.TrimSpace(os.Getenv(DIR))
//hash := strings.TrimSpace(os.Getenv(HASH))
//id := strings.TrimSpace(os.Getenv(ID))
name := strings.TrimSpace(os.Getenv(NAME))
if len(time) > 0 && len(dir) > 0 && len(name) > 0 {
title := "Transmission Download Completed"
message := fmt.Sprintf("[%s] %s (at %s)", time, name, dir)
if pbhelper.SendNote(title, message) {
fmt.Println("Push was successful.")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment