Lord-Kamina / Deluge-Magnet-Handler

OSX Applescript handler to open magnet URLs in Deluge.app
Other
91 stars 6 forks source link

Patched code for deluge v2 + ability to handle files #9

Open Olie440 opened 9 months ago

Olie440 commented 9 months ago

Hi,

I'm aware that this is only for v1 of deluge but for anyone who has got v2 installed with these instructions https://help.rapidseedbox.com/en/articles/6177931-install-deluge-v2-on-macos I've managed to update the script to work with it. I've also added a open handler that you can use to open torrent files in v2:

on openDeluge(torrentPath)
    set sanitizedPath to quoted form of torrentPath
    do shell script "/usr/local/bin/deluge-gtk " & sanitizedPath & " > /dev/null 2>&1 &"

    tell application "System Events"
        repeat until (exists process "Python")
            delay 0.05
        end repeat

        tell process "Python"
            set frontmost to true
            windows where title contains "Deluge"
            if result is not {} then perform action "AXRaise" of item 1 of result
        end tell
    end tell
end openDeluge

on convertFileListToPaths(fileList)
    set filePaths to ""

    repeat with i from 1 to count of fileList
        set currentFile to item i of fileList
        set filePaths to filePaths & POSIX path of currentFile

        if i is not equal to (count of fileList) then
            set filePaths to filePaths & " "
        end if
    end repeat

    return filePaths
end convertFileListToPaths

on open location magnetUrl
    openDeluge(magnetUrl)
end open location

on open fileList
    openDeluge(convertFileListToPaths(fileList))
end open

Hopefully someone finds this helpful and maybe can even find a way to detect v2 and run this as well

Lord-Kamina commented 9 months ago

Nice. I won't be working anymore on this but if a good pull request is sent, I have no issues merging it.

FWIW, there I upload an app bundle of an old Deluge 2.0.4 build that I modded and that can open magnets, among a few other changes.

I haven't updated it in ages though, mostly due to some differences of opinion with the devs, back when I made the PR.