Esempio n. 1
0
def pushbullet_notification(transaction):
    logger.info(sys._getframe().f_code.co_name)

    body = "%s: %s (%s)" % (transaction.get("description"),transaction.get("amount"),transaction.get("balance"))
    try:
        pushbullet.send(config.get_pushbullet(), get_alias(transaction), body=body)
        logger.info("ING - Movimiento: %s", body)
    except KeyError as e:
        logger.error("No hay alias para la transation: %s", transaction)
    except Exception as e:
        logger.error("Error enviando pushbullet: %s", e)
        raise e
Esempio n. 2
0
def stopTorrent(msg):
    try:
        cmd = "deluge-console pause " + args.torrent_id
        subprocess.run(cmd.split(), check=True, text=True)
        log.warning("paused torrent: " + args.torrent_name)
        pushbullet.send(["Warning: torrent paused", msg])
        sys.exit(0)
    except Exception as e:
        pushbullet.send([
            "ERROR: unable to pause", args.torrent_name +
            "\\nTorrent can't be paused, you should probably check that out"
        ])
        log.error("error: " + str(e))
Esempio n. 3
0
def save_token():
    """
    El javascript de auth_complete enviara aqui el token de la url
    """
    logger.info(sys._getframe().f_code.co_name)
    token = request.params.get("token")
    config.set_pushbullet(token)
    logger.info("Actualizando token: %s", token)

    try:
        logger.info("Probando envio de pushbullet")
        pushbullet.send(config.get_pushbullet(), "Registro correcto", body="Prueba de envio")
    except Exception as e:
        logger.error("Error enviando pushbullet: %s", e)
        raise e

    return 'Token registrando correctamente. Ahora deberias recibir un pushbullet de prueba'
Esempio n. 4
0
#!/usr/bin/env python3

import pushbullet, subprocess
from subprocess import call

call(['bash', 'backup-data.sh'])

pushbullet.send(["Backup script ran", "Plex and Deluge metadata have been backed up to /storage/external/backup"])
Esempio n. 5
0
# check to make sure it's not a whole season
cleanname = re.sub(r'\.', " ", args.torrent_name).strip()
epdata = re.search('(S(\d+)E(\d+)(?:-E(\d{2})|-(\d{2}))?)', cleanname,
                   re.IGNORECASE)

if (epdata != None):
    log.debug("has episode data, check for duplicate...")
    log.debug("cleanname = " + cleanname)
    log.debug("epdata = " + str(epdata))
    # ok, so checking for dups is going to be involved...let's notify for proper's instead for now...
    if (re.search('proper', cleanname, re.IGNORECASE)):
        # it's a 'proper' replacement dl
        log.warning("'proper' downloaded: " + cleanname)
        pushbullet.send([
            "'PROPER' downloaded:", args.torrent_name +
            "\\nCheck if the 'proper' download replaces something."
        ])
else:
    log.debug("doesn't seem to have episode data, check for full season...")
    epdata = re.search('(S(\d+) )', cleanname, re.IGNORECASE)
    if (epdata != None):
        log.debug("yup, " + args.torrent_name +
                  " seems to be an entire season...")
        stopTorrent(args.torrent_name + " seems to be an entire season")
        sys.exit(0)
    else:
        # check if it's on netflix
        log.debug("might be a movie, check for '" + cleanname +
                  "' on netflix...")
        yr = re.search('[\(|\[|" "](\d{4})[\)|\]|" "]', cleanname,
                       re.IGNORECASE)
Esempio n. 6
0
# crawl dirs and look up stuff
for root, dirs, files in os.walk(source_dir, topdown=True):
    mediaFound = False
    skipped = False
    folder = root
    log.debug("checking folder " + folder)

    # skip sending messages if there's gonna be a ton of 'em
    tooManyMessages = False
    if len(files) > 4:
        log.info("")
        tooManyMessages = True
        msg = ["Heads Up", "Processing " + str(len(files)) + " files from " + str(root.split(os.path.sep)[-2]) + os.path.sep + str(root.split(os.path.sep)[-1])]
        log.info(str(msg))
        pushbullet.send(msg, notify)

    for name in files:
        # check extensions first
        ext = Path(name).suffix.strip()
        tmdbname = ""
        if ext in data["config"]["mediaExts"]:
            # login w/tvdb api key and get token
            #################################################################################################################################
            url = "https://api.thetvdb.com/login"
            params = '{"apikey": "F4B2F3D661A7D2CD"}'
            s = requests.Session() # for tvdb/tmdb api calls
            s.headers.update({"Accept": "application/json", "Content-Type": "application/json", "User-Agent": "Mozilla/5.0"})
            r = s.post(url, data=params)

            # check for errors from tvdb api
Esempio n. 7
0
#!/usr/bin/env python3

import urllib.request, json, requests
from subprocess import call
import pushbullet

response = requests.get(
    "https://api.github.com/repos/algebraic/piscripts/contents")
githublist = json.loads(response.text)

exclude = [".gitignore", "README.md", "web"]

for item in githublist:
    if item["name"] not in exclude:
        name = item["name"]
        call(['bash', '/home/pi/scripts/download.sh', name])

pushbullet.send(
    ["GitHub Download", "Scripts have been downloaded from GitHub"])