clinton-hall / nzbToMedia

Provides NZB and Torrent postprocessing To CouchPotatoServer, SickBeard/SickRage, HeadPhones, Mylar and Gamez
GNU General Public License v3.0
672 stars 176 forks source link

Can't mix strings and bytes in path components >> Python 3.5.6 on Synology #1671

Closed MrCee closed 4 years ago

MrCee commented 4 years ago

Describe the bug Processing stops due to message in the logs 'Can't mix strings and bytes in path components'

Technical Specs

  1. Running on 'Synology DS415play'
  2. Python version '3.5.6'
  3. Download Client 'Download Station,SABnzb'
  4. Intended Media Management 'Sickchill'

Expected behavior Since linking python to 3.5.6 on Synology DS415play, TorrentToMedia.py has started throwing 'Can't mix strings and bytes in path components' error. I tested the script after changing the python version to the new location a few days ago, everything was working fine for a while. Now processing has stopped. I use TorrentToMedia.py on a scheduled task every 30 minutes.

Log

[21:29:46] [INFO]::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
[21:29:46] [INFO]::ENVIRONMENT: PAGER: more
[21:29:46] [INFO]::ENVIRONMENT: xxxxxxxxxxxxxxxxxxxxx
[21:29:46] [INFO]::ENVIRONMENT: MAIL: /var/mail/root
[21:29:46] [INFO]::ENVIRONMENT: LANG: en_US.utf8
[21:29:46] [INFO]::ENVIRONMENT: PGDATA: /var/services/pgsql
[21:29:46] [INFO]::ENVIRONMENT: HOME: /root
[21:29:46] [INFO]::ENVIRONMENT: TERMINFO: /usr/share/terminfo
[21:29:46] [INFO]::ENVIRONMENT: SSH_CONNECTION: xxxxxxxxxxxxxxxxxxxxx
[21:29:46] [INFO]::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:/opt/sbin
[21:29:46] [INFO]::ENVIRONMENT: PWD: /nzbToMedia/logs
[21:29:46] [INFO]::ENVIRONMENT: USER: root
[21:29:46] [INFO]::ENVIRONMENT: SSH_TTY: /dev/pts/2
[21:29:46] [INFO]::ENVIRONMENT: _: /nzbToMedia/TorrentToMedia.py
[21:29:46] [INFO]::ENVIRONMENT: SHELL: /bin/ash
[21:29:46] [INFO]::ENVIRONMENT: LOGNAME: xxxxxxxxxxxxxxxxxxxxx
[21:29:46] [INFO]::ENVIRONMENT: TERM: xterm-256color
[21:29:46] [INFO]::ENVIRONMENT: OLDPWD: /nzbToMedia
[21:29:46] [INFO]::ENVIRONMENT: LC_ALL: en_US.utf8
[21:29:46] [INFO]::ENVIRONMENT: SHLVL: 1
/volume1/@appstore/nzbToMedia/eol.py:146: LifetimeWarning: Python 3.5 is no longer supported.
  warnings.warn(msg, LifetimeWarning)
[21:29:46] [INFO]::MAIN: Python v3.5 will reach end of life in 306 days.
[21:29:46] [WARNING]::MAIN: Please upgrade to a more recent Python version.
[21:29:46] [INFO]::MAIN: Checking database structure...
[21:29:46] [DEBUG]::MAIN: Checking Initial Schema database upgrade
[21:29:46] [DB]::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
[21:29:46] [DB]::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
[21:29:46] [DEBUG]::MAIN: InitialSchema upgrade not required
[21:29:46] [DEBUG]::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
[21:29:46] [DEBUG]::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
[21:29:46] [DEBUG]::MAIN: git output: git version 2.15.1
[21:29:46] [DEBUG]::MAIN: "/usr/local/bin/git" version : returned successful
[21:29:46] [DEBUG]::MAIN: Using: "/usr/local/bin/git"
[21:29:46] [DEBUG]::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
[21:29:46] [DEBUG]::MAIN: git output: refs/heads/master
[21:29:46] [DEBUG]::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
[21:29:46] [INFO]::MAIN: Checking if git needs an update
[21:29:46] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
[21:29:46] [DEBUG]::MAIN: git output: 46b2e8998ce7c0e4b853272f0bdb06a558852c81
[21:29:46] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
[21:29:46] [DEBUG]::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
[21:29:48] [DEBUG]::MAIN: git output: 
[21:29:48] [DEBUG]::MAIN: "/usr/local/bin/git" fetch origin : returned successful
[21:29:48] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
[21:29:48] [DEBUG]::MAIN: git output: 46b2e8998ce7c0e4b853272f0bdb06a558852c81
[21:29:48] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
[21:29:48] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
[21:29:48] [DEBUG]::MAIN: git output: 
[21:29:48] [DEBUG]::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
[21:29:48] [DEBUG]::MAIN: cur_commit = 46b2e8998ce7c0e4b853272f0bdb06a558852c81 % (newest_commit)= 46b2e8998ce7c0e4b853272f0bdb06a558852c81, num_commits_behind = 0, num_commits_ahead = 0
[21:29:48] [INFO]::MAIN: No update needed
[21:29:48] [INFO]::MAIN: nzbToMedia Version:46b2e8998ce7c0e4b853272f0bdb06a558852c81 Branch:master (Linux 3.2.40)
[21:29:49] [INFO]::MAIN: #########################################################
[21:29:49] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[21:29:49] [INFO]::MAIN: #########################################################
[21:29:49] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['/nzbToMedia/TorrentToMedia.py']
[21:29:49] [WARNING]::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
[21:29:49] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[21:29:49] [DEBUG]::MAIN: Found file 12.Monkeys.S01E01.Splinter.BDRip.x264.mkv in root directory /volume1/downloads/tv.
[21:29:51] [ERROR]::MAIN: Failed to move 12.Monkeys.S01E01.Splinter.BDRip.x264.mkv to its own directory: Can't mix strings and bytes in path components
[21:29:51] [DEBUG]::MAIN: No directories identified in SickBeard:tv for post-processing
[21:29:51] [INFO]::MAIN: The /nzbToMedia/TorrentToMedia.py script completed successfully.
clinton-hall commented 4 years ago

Can you update to clinton-hall-#1671~branch and test?

Looks like not too many people have been testing the manual processing with Python3

MrCee commented 4 years ago

This worked well, thanks very much Clinton. Appreciate all the work that's gone in to this.

2019-11-13 11:42:01 INFO    ::MAIN: #########################################################
2019-11-13 11:42:01 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-11-13 11:42:01 INFO    ::MAIN: #########################################################
2019-11-13 11:42:01 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/nzbToMedia/TorrentToMedia.py']
2019-11-13 11:42:01 WARNING ::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
2019-11-13 11:42:01 INFO    ::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
2019-11-13 11:42:01 DEBUG   ::MAIN: Found file 12.Monkeys.S01E01.Splinter.BDRip.x264.mkv in root directory /volume1/downloads/tv.
2019-11-13 11:42:04 INFO    ::COPYLINK: MEDIAFILE: [b'12.Monkeys.S01E01.Splinter.BDRip.x264.mkv']
2019-11-13 11:42:04 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
2019-11-13 11:42:04 INFO    ::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/12 Monkeys']
2019-11-13 11:42:04 INFO    ::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
2019-11-13 11:42:04 INFO    ::MAIN: Starting manual run for SickBeard:tv - Folder:/volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 INFO    ::MAIN: Checking database for download info for 12 Monkeys ...
2019-11-13 11:42:04 DB      ::DB: Getting download info for 12 Monkeys from the DB
2019-11-13 11:42:04 DB      ::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['12 Monkeys', 0]
2019-11-13 11:42:04 INFO    ::MAIN: Unable to locate download info for 12 Monkeys, continuing to try and process this release ...
2019-11-13 11:42:04 DEBUG   ::MAIN: Received Directory: /volume1/downloads/tv/12 Monkeys | Name: 12 Monkeys | Category: tv
2019-11-13 11:42:04 DEBUG   ::MAIN: SEARCH: Found the Category: tv in directory structure
2019-11-13 11:42:04 INFO    ::MAIN: SEARCH: Found a unique directory 12 Monkeys in the category directory
2019-11-13 11:42:04 DEBUG   ::MAIN: Determined Directory: /volume1/downloads/tv/12 Monkeys | Name: 12 Monkeys | Category: tv
2019-11-13 11:42:04 INFO    ::MAIN: Auto-detected SECTION:SickBeard
2019-11-13 11:42:04 INFO    ::MAIN: Output directory set to: /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 DEBUG   ::MAIN: Scanning files in directory: /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 DEBUG   ::MAIN: Found 1 files in /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 INFO    ::COPYLINK: MEDIAFILE: [12.Monkeys.S01E01.Splinter.BDRip.x264.mkv]
2019-11-13 11:42:04 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv/12 Monkeys]
2019-11-13 11:42:04 INFO    ::COPYLINK: TARGET FOLDER: [/volume1/downloads/tv/12 Monkeys]
2019-11-13 11:42:04 INFO    ::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
2019-11-13 11:42:04 DEBUG   ::MAIN: Checking for archives to extract in directory: /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 INFO    ::MAIN: FLATTEN: Flattening directory: /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 DEBUG   ::MAIN: Checking for empty folders in:/volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 INFO    ::MAIN: Found 1 media files in /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:04 INFO    ::MAIN: Calling SickBeard:tv to post-process:12 Monkeys
2019-11-13 11:42:04 DEBUG   ::SERVER: Attempting to connect to server at http://localhost:8083
2019-11-13 11:42:08 DEBUG   ::SERVER: Server responded at http://localhost:8083
2019-11-13 11:42:08 INFO    ::MAIN: SickBeard:tv fork set to SickChill
2019-11-13 11:42:08 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/te$
2019-11-13 11:42:10 INFO    ::TRANSCODER: Checking [12.Monkeys.S01E01.Splinter.BDRip.x264.mkv] for corruption, please stand by ...
2019-11-13 11:42:10 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/tv/12 Monkeys/12.Mo$
2019-11-13 11:42:12 INFO    ::TRANSCODER: SUCCESS: [12.Monkeys.S01E01.Splinter.BDRip.x264.mkv] has no corruption.
2019-11-13 11:42:12 POSTPROCESS::SICKBEARD: SUCCESS: The download succeeded, sending a post-process request
2019-11-13 11:42:12 DEBUG   ::SICKBEARD: Opening URL: http://localhost:8083/api/be87600ad695b39a8071fa6a4851f8ad/?cmd=postprocess with params: {'failed': 0, 'process_method': 'move', 'quiet': 1, '$
2019-11-13 11:42:27 DEBUG   ::PLEX: Attempting to update Plex Library for category tv.
2019-11-13 11:42:27 DEBUG   ::PLEX: Could not identify section for plex update
2019-11-13 11:42:27 INFO    ::CLEANDIR: Doing Forceful Clean of /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:27 INFO    ::MAIN: Deleting /volume1/downloads/tv/12 Monkeys
2019-11-13 11:42:27 INFO    ::MAIN: The /nzbToMedia/TorrentToMedia.py script completed successfully.
clinton-hall commented 4 years ago

Ok, I have merged that into nightly. If you switch to nightly, you'll get further updates. I hope to merge everything up to master and do a new release soon.

MrCee commented 4 years ago

Although I had previously tested using [[tv]] & Sickchill, Is there a chance this could also be occurring with a manual run of TorrentToMedia.py for [[movie]] using Radarr? JSON object must be str, not 'bytes'

2019-11-30 14:13:16 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/movie/Nightmare.Cin$
2019-11-30 14:13:16 INFO    ::TRANSCODER: SUCCESS: [Nightmare.Cinema.2018.HDRip.AC3.x264-CMRG.mkv] has no corruption.
2019-11-30 14:13:16 DEBUG   ::RADARR: Opening URL: http://localhost:8310/api/command with PARAMS: {'path': '/volume1/downloads/movie/Nightmare.Cinema.2018.HDRip.AC3.x264-CMRG-franky007', 'importMo$
2019-11-30 14:13:16 POSTPROCESS::RADARR: Starting DownloadedMoviesScan scan for Nightmare.Cinema.2018.HDRip.AC3.x264-CMRG-franky007
2019-11-30 14:13:16 POSTPROCESS::POSTPROCESS: Radarr response: queued
2019-11-30 14:13:16 WARNING ::RADARR: No scan id was returned due to: the JSON object must be str, not 'bytes'
2019-11-30 14:13:16 POSTPROCESS::RADARR: Checking for status change, please stand by ...
2019-11-30 14:14:16 POSTPROCESS::RADARR: Checking for status change, please stand by ...
2019-11-30 14:15:16 POSTPROCESS::RADARR: Checking for status change, please stand by ...
2019-11-30 14:16:16 POSTPROCESS::RADARR: Checking for status change, please stand by ...
2019-11-30 14:17:16 POSTPROCESS::RADARR: Checking for status change, please stand by ...
2019-11-30 14:18:17 POSTPROCESS::RADARR: Checking for status change, please stand by ...
2019-11-30 14:19:19 DEBUG   ::RADARR: The Scan command did not return status completed, but complete Download Handling is enabled. Passing back to Radarr.
2019-11-30 14:19:19 DEBUG   ::PLEX: Attempting to update Plex Library for category movie.
2019-11-30 14:19:20 DEBUG   ::PLEX: Plex Library has been refreshed.
clinton-hall commented 4 years ago

where was the error logged?

This error is different to the OP, but never the less I would like to fix this. I just need to know where the error is ocuring.

MrCee commented 4 years ago

There's no error being logged here unfortunately.

clinton-hall commented 4 years ago

@MrCee JSON object must be str, not 'bytes' Where did you see that?

MrCee commented 4 years ago

As a warning in the log.....

2019-11-30 14:13:16 WARNING ::RADARR: No scan id was returned due to: the JSON object must be str, not 'bytes'

It causes the script to hang for 5 minutes with the message .... POSTPROCESS::RADARR: Checking for status change, please stand by ...

followed by:

2019-11-30 14:19:19 DEBUG   ::RADARR: The Scan command did not return status completed, but complete Download Handling is enabled. Passing back to Radarr.
clinton-hall commented 4 years ago

Can you switch to json-patch-1 branch and try again? I hope this branch has a fix that will resolve this issue.

MrCee commented 4 years ago

@clinton-hall This has worked, but only when Radarr in autoconfig.cfg is set to 'Copy'

It might be good to note now that MYMOVIEFILE.mkv gets copied to a newly created directory e.g./downloads/movie/MYMOVIE/MYMOVIEFILE.mkv and during a forceful clean this directory is removed, but it leaves the original in /downloads/movie/MYMOVIEFILE.mkvas well as being copied to the final library destination.

When Radarr in autoconfig.cfg is set to 'Move', the files are not moved to the final library destination.

clinton-hall commented 4 years ago

Do you have logs to show the behavior for both move and copy?

Please also check autoProcesMedia.cfg

[Radarr]
    [[movie]] <<or what ever the category is>>
                importMode = Move

if this value is set to copy, that will over-ride, or conflict, with the setting in Radarr. You can also try setting this blank importMode = ""

Also, when set to move, check the Radarr logs at the time of postprocessing to see if there are any errors reported in Radarr.

I suspect from what you are describing, the script handles these the same... to remove the /downloads/movie/MYMOVIEFILE.mkv this would require autoProcessMedia.cfg

[Torrent]
    deleteOriginal = 1
MrCee commented 4 years ago

I managed to get Move & Copy both working by checking Radarr logs thank you.

The importMode = Move required [Torrent] chmodDirectory = 0777 in autoProcessMedia.cfg to allow the attempted move. Note that I'm using DownloadStation on Synology so the script doesn't interact with clientAgent = other (as far as I'm aware), but for some reason using Radarr the remaining file won't be deleted after the self-contained folder for processing was created.

This isn't a current issue with SickChill or when I had previously used CouchPotato for Torrents.

I have since carefully gone through the Radarr config to minimise potential conflicts and I am not setting permissions in Radarr. I do have final files all moved to the final destination on the same volume, but just can't seem get rid of the original file which is not contained in any folder and don't really understand the COPYLINK section or why it repeats in the same way.

I have really tried not to miss anything here. I'll keep my config as is for the time being just incase there is something I have overlooked.

[Torrent]
    ###### clientAgent - Supported clients: utorrent, transmission, deluge, rtorrent, vuze, qbittorrent, other
    clientAgent = other
    ###### useLink - Set to hard for physical links, sym for symbolic links, move to move, move-sym to move and link back, and no to not use links (copy)
    useLink = move
    ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
    deleteOriginal = 1
    chmodDirectory = 0777
    resume = 1
    resumeOnFailure = 1
[Radarr]
    #### autoProcessing for Movies
    #### raCategory - category that gets called for post-processing with Radarr
    [[movie]]
        enabled = 1
        ###### ADVANCED USE - ONLY EDIT IF YOU KNOW WHAT YOU'RE DOING ######
        web_root = ""
        ssl = 0
        # api key for www.omdbapi.com (used as alternative to imdb)
        omdbapikey = ""
        delete_failed = 1
        # Enable/Disable linking for Torrents
        Torrent_NoLink = 0
        keep_archive = 0
        extract = 1
        nzbExtractionBy = Downloader
        wait_for = 6
        # Set this to minimum required size to consider a media file valid (in MB)
        minSize = 100
        # Enable/Disable deleting ignored files (samples and invalid media files)
        delete_ignored = 0
        ##### Enable if NzbDrone is on a remote server for this category
        remote_path = 0
        ##### Set to path where download client places completed downloads locally for this category
        watch_dir = /volume1/downloads/movie
        ##### Set to define import behavior Move or Copy
        importMode = Move

This is the result when importMode = Move nzbtomedia.log

[18:09:14] [INFO]::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
[18:09:14] [INFO]::ENVIRONMENT: MAIL: /var/mail/root
[18:09:14] [INFO]::ENVIRONMENT: SHLVL: 1
[18:09:14] [INFO]::ENVIRONMENT: SSH_TTY: /dev/pts/1
[18:09:14] [INFO]::ENVIRONMENT: HOME: /root
[18:09:14] [INFO]::ENVIRONMENT: USER: root
[18:09:14] [INFO]::ENVIRONMENT: SSH_CLIENT: XXXXXXXXXXXXXXXXXXXXXXXXXXX
[18:09:14] [INFO]::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:/opt/sbin
[18:09:14] [INFO]::ENVIRONMENT: SHELL: /bin/ash
[18:09:14] [INFO]::ENVIRONMENT: TERM: xterm-256color
[18:09:14] [INFO]::ENVIRONMENT: LANG: en_US.utf8
[18:09:14] [INFO]::ENVIRONMENT: PGDATA: /var/services/pgsql
[18:09:14] [INFO]::ENVIRONMENT: SSH_CONNECTION: XXXXXXXXXXXXXXXXXXXXXXXXXXX
[18:09:14] [INFO]::ENVIRONMENT: _: ./TorrentToMedia.py
[18:09:14] [INFO]::ENVIRONMENT: LOGNAME: root
[18:09:14] [INFO]::ENVIRONMENT: OLDPWD: /root
[18:09:14] [INFO]::ENVIRONMENT: LC_ALL: en_US.utf8
[18:09:14] [INFO]::ENVIRONMENT: PAGER: more
[18:09:14] [INFO]::ENVIRONMENT: TERMINFO: /usr/share/terminfo
[18:09:14] [INFO]::ENVIRONMENT: PWD: /nzbToMedia
/volume1/@appstore/nzbToMedia/eol.py:147: LifetimeWarning: Python 3.5 is no longer supported.
  warnings.warn(msg, LifetimeWarning)
[18:09:14] [INFO]::MAIN: Python v3.5 will reach end of life in 284 days.
[18:09:14] [WARNING]::MAIN: Please upgrade to a more recent Python version.
[18:09:14] [INFO]::MAIN: Checking database structure...
[18:09:14] [DEBUG]::MAIN: Checking Initial Schema database upgrade
[18:09:14] [DB]::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
[18:09:14] [DB]::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
[18:09:14] [DEBUG]::MAIN: InitialSchema upgrade not required
[18:09:14] [DEBUG]::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
[18:09:14] [DEBUG]::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
[18:09:14] [DEBUG]::MAIN: git output: git version 2.15.1
[18:09:14] [DEBUG]::MAIN: "/usr/local/bin/git" version : returned successful
[18:09:14] [DEBUG]::MAIN: Using: "/usr/local/bin/git"
[18:09:14] [DEBUG]::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:09:14] [DEBUG]::MAIN: git output: refs/heads/json-patch-1
[18:09:14] [DEBUG]::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
[18:09:14] [INFO]::MAIN: Checking if git needs an update
[18:09:14] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:09:14] [DEBUG]::MAIN: git output: df7f996796be95df7a77ba4713185d2e23383cb8
[18:09:14] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
[18:09:14] [DEBUG]::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
[18:09:41] [DEBUG]::MAIN: git output: 
[18:09:41] [DEBUG]::MAIN: "/usr/local/bin/git" fetch origin : returned successful
[18:09:41] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
[18:09:41] [DEBUG]::MAIN: git output: df7f996796be95df7a77ba4713185d2e23383cb8
[18:09:41] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
[18:09:41] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:09:41] [DEBUG]::MAIN: git output: 
[18:09:41] [DEBUG]::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
[18:09:41] [DEBUG]::MAIN: cur_commit = df7f996796be95df7a77ba4713185d2e23383cb8 % (newest_commit)= df7f996796be95df7a77ba4713185d2e23383cb8, num_commits_behind = 0, num_commits_ahead = 0
[18:09:41] [INFO]::MAIN: No update needed
[18:09:42] [INFO]::MAIN: nzbToMedia Version:df7f996796be95df7a77ba4713185d2e23383cb8 Branch:json-patch-1 (Linux 3.2.40)
[18:09:42] [INFO]::MAIN: #########################################################
[18:09:42] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[18:09:42] [INFO]::MAIN: #########################################################
[18:09:42] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['./TorrentToMedia.py']
[18:09:42] [WARNING]::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
[18:09:42] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[18:09:42] [DEBUG]::MAIN: Found file Joker 2019 1080p HCHDRip x264 - JusTiN.mkv in root directory /volume1/downloads/movie.
[18:09:44] [INFO]::COPYLINK: MEDIAFILE: [b'Joker 2019 1080p HCHDRip x264 - JusTiN.mkv']
[18:09:44] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie]
[18:09:44] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/movie/Joker']
[18:09:44] [INFO]::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
[18:09:44] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[18:09:44] [DEBUG]::MAIN: Found file Joker 2019 1080p HCHDRip x264 - JusTiN.mkv in root directory /volume1/downloads/movie.
[18:09:44] [INFO]::COPYLINK: MEDIAFILE: [b'Joker 2019 1080p HCHDRip x264 - JusTiN.mkv']
[18:09:44] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie]
[18:09:44] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/movie/Joker']
[18:09:44] [INFO]::COPYLINK: MEDIAFILE already exists in the TARGET folder, skipping ...
[18:09:44] [INFO]::MAIN: Starting manual run for Radarr:movie - Folder:/volume1/downloads/movie/Joker
[18:09:44] [INFO]::MAIN: Checking database for download info for Joker ...
[18:09:44] [DB]::DB: Getting download info for Joker from the DB
[18:09:44] [DB]::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['Joker', 0]
[18:09:44] [INFO]::MAIN: Unable to locate download info for Joker, continuing to try and process this release ...
[18:09:44] [DEBUG]::MAIN: Received Directory: /volume1/downloads/movie/Joker | Name: Joker | Category: movie
[18:09:44] [DEBUG]::MAIN: SEARCH: Found the Category: movie in directory structure
[18:09:44] [INFO]::MAIN: SEARCH: Found a unique directory Joker in the category directory
[18:09:44] [DEBUG]::MAIN: Determined Directory: /volume1/downloads/movie/Joker | Name: Joker | Category: movie
[18:09:45] [INFO]::MAIN: Auto-detected SECTION:Radarr
[18:09:45] [INFO]::MAIN: Output directory set to: /volume1/downloads/movie/Joker
[18:09:45] [DEBUG]::MAIN: Scanning files in directory: /volume1/downloads/movie/Joker
[18:09:45] [DEBUG]::MAIN: Found 1 files in /volume1/downloads/movie/Joker
[18:09:45] [INFO]::COPYLINK: MEDIAFILE: [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv]
[18:09:45] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie/Joker]
[18:09:45] [INFO]::COPYLINK: TARGET FOLDER: [/volume1/downloads/movie/Joker]
[18:09:45] [INFO]::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
[18:09:45] [DEBUG]::MAIN: Checking for archives to extract in directory: /volume1/downloads/movie/Joker
[18:09:45] [INFO]::MAIN: FLATTEN: Flattening directory: /volume1/downloads/movie/Joker
[18:09:45] [DEBUG]::MAIN: Checking for empty folders in:/volume1/downloads/movie/Joker
[18:09:45] [INFO]::MAIN: Found 1 media files in /volume1/downloads/movie/Joker
[18:09:45] [INFO]::MAIN: Calling Radarr:movie to post-process:Joker
[18:09:45] [INFO]::MAIN: Changing file mode of /volume1/downloads/movie/Joker to 0o777
[18:09:45] [INFO]::MAIN: Attemping imdbID lookup for Joker
[18:09:45] [INFO]::MAIN: Searching folder and file names for imdbID ...
[18:09:45] [INFO]::MAIN: Searching IMDB for imdbID ...
[18:09:45] [INFO]::MAIN: Unable to determine imdbID: No api key provided for ombdapi.com.
[18:09:45] [DEBUG]::SERVER: Attempting to connect to server at http://localhost:8310/api/command
[18:09:45] [DEBUG]::SERVER: Server responded at http://localhost:8310/api/command
[18:09:45] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
[18:09:46] [INFO]::TRANSCODER: Checking [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv] for corruption, please stand by ...
[18:09:46] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/movie/Joker/Joker 2019 1080p HCHDRip x264 - JusTiN.mkv
[18:09:47] [INFO]::TRANSCODER: SUCCESS: [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv] has no corruption.
[18:09:47] [DEBUG]::RADARR: Opening URL: http://localhost:8310/api/command with PARAMS: {'path': '/volume1/downloads/movie/Joker', 'importMode': 'Move', 'name': 'DownloadedMoviesScan'}
[18:09:47] [POSTPROCESS]::RADARR: Starting DownloadedMoviesScan scan for Joker
[18:09:47] [POSTPROCESS]::POSTPROCESS: Radarr response: queued
[18:09:47] [DEBUG]::RADARR: Scan started with id: 361161
[18:09:47] [POSTPROCESS]::RADARR: Checking for status change, please stand by ...
[18:09:47] [DEBUG]::RADARR: The Scan command return status: started
[18:10:47] [POSTPROCESS]::RADARR: Checking for status change, please stand by ...
[18:10:47] [DEBUG]::RADARR: The Scan command return status: completed
[18:10:47] [DEBUG]::RADARR: The Scan command has completed successfully. Renaming was successful.
[18:10:47] [DEBUG]::PLEX: Attempting to update Plex Library for category movie.
[18:10:48] [DEBUG]::PLEX: Plex Library has been refreshed.
[18:10:48] [INFO]::CLEANDIR: Directory /volume1/downloads/movie/Joker has been processed and removed ...
[18:10:48] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[18:10:48] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[18:10:48] [DEBUG]::MAIN: No directories identified in SickBeard:tv for post-processing
[18:10:48] [INFO]::MAIN: The ./TorrentToMedia.py script completed successfully.

This is the result when importMode = Copy nzbtomedia.log

[18:17:30] [INFO]::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
[18:17:30] [INFO]::ENVIRONMENT: MAIL: /var/mail/root
[18:17:30] [INFO]::ENVIRONMENT: _: ./TorrentToMedia.py
[18:17:30] [INFO]::ENVIRONMENT: OLDPWD: /root
[18:17:30] [INFO]::ENVIRONMENT: HOME: /root
[18:17:30] [INFO]::ENVIRONMENT: SSH_TTY: /dev/pts/1
[18:17:30] [INFO]::ENVIRONMENT: LOGNAME: root
[18:17:30] [INFO]::ENVIRONMENT: SHLVL: 1
[18:17:30] [INFO]::ENVIRONMENT: SSH_CLIENT: XXXXXXXXXXXXXXXXXXXXXXXXXXX
[18:17:30] [INFO]::ENVIRONMENT: LANG: en_US.utf8
[18:17:30] [INFO]::ENVIRONMENT: PWD: /nzbToMedia
[18:17:30] [INFO]::ENVIRONMENT: PGDATA: /var/services/pgsql
[18:17:30] [INFO]::ENVIRONMENT: SSH_CONNECTION: XXXXXXXXXXXXXXXXXXXXXXXXXXX
[18:17:30] [INFO]::ENVIRONMENT: USER: root
[18:17:30] [INFO]::ENVIRONMENT: LC_ALL: en_US.utf8
[18:17:30] [INFO]::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:/opt/sbin
[18:17:30] [INFO]::ENVIRONMENT: SHELL: /bin/ash
[18:17:30] [INFO]::ENVIRONMENT: TERMINFO: /usr/share/terminfo
[18:17:30] [INFO]::ENVIRONMENT: PAGER: more
[18:17:30] [INFO]::ENVIRONMENT: TERM: xterm-256color
/volume1/@appstore/nzbToMedia/eol.py:147: LifetimeWarning: Python 3.5 is no longer supported.
  warnings.warn(msg, LifetimeWarning)
[18:17:30] [INFO]::MAIN: Python v3.5 will reach end of life in 284 days.
[18:17:30] [WARNING]::MAIN: Please upgrade to a more recent Python version.
[18:17:30] [INFO]::MAIN: Checking database structure...
[18:17:30] [DEBUG]::MAIN: Checking Initial Schema database upgrade
[18:17:30] [DB]::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
[18:17:30] [DB]::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
[18:17:30] [DEBUG]::MAIN: InitialSchema upgrade not required
[18:17:30] [DEBUG]::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
[18:17:30] [DEBUG]::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
[18:17:30] [DEBUG]::MAIN: git output: git version 2.15.1
[18:17:30] [DEBUG]::MAIN: "/usr/local/bin/git" version : returned successful
[18:17:30] [DEBUG]::MAIN: Using: "/usr/local/bin/git"
[18:17:30] [DEBUG]::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:17:30] [DEBUG]::MAIN: git output: refs/heads/json-patch-1
[18:17:30] [DEBUG]::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
[18:17:30] [INFO]::MAIN: Checking if git needs an update
[18:17:30] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:17:30] [DEBUG]::MAIN: git output: df7f996796be95df7a77ba4713185d2e23383cb8
[18:17:30] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
[18:17:30] [DEBUG]::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
[18:17:37] [DEBUG]::MAIN: git output: 
[18:17:37] [DEBUG]::MAIN: "/usr/local/bin/git" fetch origin : returned successful
[18:17:37] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
[18:17:37] [DEBUG]::MAIN: git output: df7f996796be95df7a77ba4713185d2e23383cb8
[18:17:37] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
[18:17:37] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:17:37] [DEBUG]::MAIN: git output: 
[18:17:37] [DEBUG]::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
[18:17:37] [DEBUG]::MAIN: cur_commit = df7f996796be95df7a77ba4713185d2e23383cb8 % (newest_commit)= df7f996796be95df7a77ba4713185d2e23383cb8, num_commits_behind = 0, num_commits_ahead = 0
[18:17:37] [INFO]::MAIN: No update needed
[18:17:37] [INFO]::MAIN: nzbToMedia Version:df7f996796be95df7a77ba4713185d2e23383cb8 Branch:json-patch-1 (Linux 3.2.40)
[18:17:38] [INFO]::MAIN: #########################################################
[18:17:38] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[18:17:38] [INFO]::MAIN: #########################################################
[18:17:38] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['./TorrentToMedia.py']
[18:17:38] [WARNING]::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
[18:17:38] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[18:17:38] [DEBUG]::MAIN: Found file Joker 2019 1080p HCHDRip x264 - JusTiN.mkv in root directory /volume1/downloads/movie.
[18:17:40] [INFO]::COPYLINK: MEDIAFILE: [b'Joker 2019 1080p HCHDRip x264 - JusTiN.mkv']
[18:17:40] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie]
[18:17:40] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/movie/Joker']
[18:17:40] [INFO]::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
[18:17:40] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[18:17:40] [DEBUG]::MAIN: Found file Joker 2019 1080p HCHDRip x264 - JusTiN.mkv in root directory /volume1/downloads/movie.
[18:17:40] [INFO]::COPYLINK: MEDIAFILE: [b'Joker 2019 1080p HCHDRip x264 - JusTiN.mkv']
[18:17:40] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie]
[18:17:40] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/movie/Joker']
[18:17:40] [INFO]::COPYLINK: MEDIAFILE already exists in the TARGET folder, skipping ...
[18:17:40] [INFO]::MAIN: Starting manual run for Radarr:movie - Folder:/volume1/downloads/movie/Joker
[18:17:40] [INFO]::MAIN: Checking database for download info for Joker ...
[18:17:40] [DB]::DB: Getting download info for Joker from the DB
[18:17:40] [DB]::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['Joker', 0]
[18:17:40] [INFO]::MAIN: Unable to locate download info for Joker, continuing to try and process this release ...
[18:17:40] [DEBUG]::MAIN: Received Directory: /volume1/downloads/movie/Joker | Name: Joker | Category: movie
[18:17:40] [DEBUG]::MAIN: SEARCH: Found the Category: movie in directory structure
[18:17:40] [INFO]::MAIN: SEARCH: Found a unique directory Joker in the category directory
[18:17:40] [DEBUG]::MAIN: Determined Directory: /volume1/downloads/movie/Joker | Name: Joker | Category: movie
[18:17:40] [INFO]::MAIN: Auto-detected SECTION:Radarr
[18:17:40] [INFO]::MAIN: Output directory set to: /volume1/downloads/movie/Joker
[18:17:40] [DEBUG]::MAIN: Scanning files in directory: /volume1/downloads/movie/Joker
[18:17:40] [DEBUG]::MAIN: Found 1 files in /volume1/downloads/movie/Joker
[18:17:40] [INFO]::COPYLINK: MEDIAFILE: [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv]
[18:17:40] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie/Joker]
[18:17:40] [INFO]::COPYLINK: TARGET FOLDER: [/volume1/downloads/movie/Joker]
[18:17:40] [INFO]::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
[18:17:40] [DEBUG]::MAIN: Checking for archives to extract in directory: /volume1/downloads/movie/Joker
[18:17:40] [INFO]::MAIN: FLATTEN: Flattening directory: /volume1/downloads/movie/Joker
[18:17:40] [DEBUG]::MAIN: Checking for empty folders in:/volume1/downloads/movie/Joker
[18:17:40] [INFO]::MAIN: Found 1 media files in /volume1/downloads/movie/Joker
[18:17:40] [INFO]::MAIN: Calling Radarr:movie to post-process:Joker
[18:17:40] [INFO]::MAIN: Changing file mode of /volume1/downloads/movie/Joker to 0o777
[18:17:40] [INFO]::MAIN: Attemping imdbID lookup for Joker
[18:17:40] [INFO]::MAIN: Searching folder and file names for imdbID ...
[18:17:40] [INFO]::MAIN: Searching IMDB for imdbID ...
[18:17:41] [INFO]::MAIN: Unable to determine imdbID: No api key provided for ombdapi.com.
[18:17:41] [DEBUG]::SERVER: Attempting to connect to server at http://localhost:8310/api/command
[18:17:41] [DEBUG]::SERVER: Server responded at http://localhost:8310/api/command
[18:17:41] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
[18:17:42] [INFO]::TRANSCODER: Checking [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv] for corruption, please stand by ...
[18:17:42] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/movie/Joker/Joker 2019 1080p HCHDRip x264 - JusTiN.mkv
[18:17:43] [INFO]::TRANSCODER: SUCCESS: [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv] has no corruption.
[18:17:43] [DEBUG]::RADARR: Opening URL: http://localhost:8310/api/command with PARAMS: {'path': '/volume1/downloads/movie/Joker', 'name': 'DownloadedMoviesScan', 'importMode': 'Copy'}
[18:17:43] [POSTPROCESS]::RADARR: Starting DownloadedMoviesScan scan for Joker
[18:17:43] [POSTPROCESS]::POSTPROCESS: Radarr response: started
[18:17:43] [DEBUG]::RADARR: Scan started with id: 361172
[18:17:43] [POSTPROCESS]::RADARR: Checking for status change, please stand by ...
[18:17:43] [DEBUG]::RADARR: The Scan command return status: started
[18:18:44] [POSTPROCESS]::RADARR: Checking for status change, please stand by ...
[18:18:44] [DEBUG]::RADARR: The Scan command return status: completed
[18:18:44] [DEBUG]::RADARR: The Scan command has completed successfully. Renaming was successful.
[18:18:44] [DEBUG]::PLEX: Attempting to update Plex Library for category movie.
[18:18:44] [DEBUG]::PLEX: Plex Library has been refreshed.
[18:18:44] [INFO]::CLEANDIR: Doing Forceful Clean of /volume1/downloads/movie/Joker
[18:18:44] [INFO]::MAIN: Deleting /volume1/downloads/movie/Joker
[18:18:44] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[18:18:44] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[18:18:44] [DEBUG]::MAIN: No directories identified in SickBeard:tv for post-processing
[18:18:44] [INFO]::MAIN: The ./TorrentToMedia.py script completed successfully.

One last example I have for you. This is the result when importMode = Move & [Torrent] chmodDirectory = 0 as Radarr cannot access and file which is not moved to the final destination, although I'm not seeing an error in nzbtomedia.log

RADARR LOG Couldn't import movie /volume1/downloads/movie/Joker/Joker 2019 1080p HCHDRip x264 - JusTiN.mkv: Access to the path is denied.

nzbtomedia.log

[18:46:16] [INFO]::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
[18:46:16] [INFO]::ENVIRONMENT: TERMINFO: /usr/share/terminfo
[18:46:16] [INFO]::ENVIRONMENT: SSH_CONNECTION: XXXXXXXXXXXXXXXXXXXXXXXXXXX
[18:46:16] [INFO]::ENVIRONMENT: USER: root
[18:46:16] [INFO]::ENVIRONMENT: LOGNAME: root
[18:46:16] [INFO]::ENVIRONMENT: SSH_TTY: /dev/pts/1
[18:46:16] [INFO]::ENVIRONMENT: PWD: /nzbToMedia
[18:46:16] [INFO]::ENVIRONMENT: HOME: /root
[18:46:16] [INFO]::ENVIRONMENT: TERM: xterm-256color
[18:46:16] [INFO]::ENVIRONMENT: OLDPWD: /root
[18:46:16] [INFO]::ENVIRONMENT: _: ./TorrentToMedia.py
[18:46:16] [INFO]::ENVIRONMENT: PGDATA: /var/services/pgsql
[18:46:16] [INFO]::ENVIRONMENT: SSH_CLIENT: XXXXXXXXXXXXXXXXXXXXXXXXXXX
[18:46:16] [INFO]::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin:/opt/bin:/opt/sbin
[18:46:16] [INFO]::ENVIRONMENT: SHLVL: 1
[18:46:16] [INFO]::ENVIRONMENT: LANG: en_US.utf8
[18:46:16] [INFO]::ENVIRONMENT: LC_ALL: en_US.utf8
[18:46:16] [INFO]::ENVIRONMENT: MAIL: /var/mail/root
[18:46:16] [INFO]::ENVIRONMENT: PAGER: more
[18:46:16] [INFO]::ENVIRONMENT: SHELL: /bin/ash
/volume1/@appstore/nzbToMedia/eol.py:147: LifetimeWarning: Python 3.5 is no longer supported.
  warnings.warn(msg, LifetimeWarning)
[18:46:16] [INFO]::MAIN: Python v3.5 will reach end of life in 284 days.
[18:46:16] [WARNING]::MAIN: Please upgrade to a more recent Python version.
[18:46:16] [INFO]::MAIN: Checking database structure...
[18:46:16] [DEBUG]::MAIN: Checking Initial Schema database upgrade
[18:46:16] [DB]::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
[18:46:16] [DB]::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
[18:46:16] [DEBUG]::MAIN: InitialSchema upgrade not required
[18:46:16] [DEBUG]::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
[18:46:16] [DEBUG]::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
[18:46:16] [DEBUG]::MAIN: git output: git version 2.15.1
[18:46:16] [DEBUG]::MAIN: "/usr/local/bin/git" version : returned successful
[18:46:16] [DEBUG]::MAIN: Using: "/usr/local/bin/git"
[18:46:16] [DEBUG]::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:46:16] [DEBUG]::MAIN: git output: refs/heads/json-patch-1
[18:46:16] [DEBUG]::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
[18:46:16] [INFO]::MAIN: Checking if git needs an update
[18:46:16] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:46:16] [DEBUG]::MAIN: git output: df7f996796be95df7a77ba4713185d2e23383cb8
[18:46:16] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
[18:46:16] [DEBUG]::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
[18:46:28] [DEBUG]::MAIN: git output: 
[18:46:28] [DEBUG]::MAIN: "/usr/local/bin/git" fetch origin : returned successful
[18:46:28] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
[18:46:28] [DEBUG]::MAIN: git output: df7f996796be95df7a77ba4713185d2e23383cb8
[18:46:28] [DEBUG]::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
[18:46:28] [DEBUG]::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
[18:46:28] [DEBUG]::MAIN: git output: 
[18:46:28] [DEBUG]::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
[18:46:28] [DEBUG]::MAIN: cur_commit = df7f996796be95df7a77ba4713185d2e23383cb8 % (newest_commit)= df7f996796be95df7a77ba4713185d2e23383cb8, num_commits_behind = 0, num_commits_ahead = 0
[18:46:28] [INFO]::MAIN: No update needed
[18:46:29] [INFO]::MAIN: nzbToMedia Version:df7f996796be95df7a77ba4713185d2e23383cb8 Branch:json-patch-1 (Linux 3.2.40)
[18:46:30] [INFO]::MAIN: #########################################################
[18:46:30] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[18:46:30] [INFO]::MAIN: #########################################################
[18:46:30] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['./TorrentToMedia.py']
[18:46:30] [WARNING]::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
[18:46:30] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[18:46:30] [DEBUG]::MAIN: Found file Joker 2019 1080p HCHDRip x264 - JusTiN.mkv in root directory /volume1/downloads/movie.
[18:46:31] [INFO]::COPYLINK: MEDIAFILE: [b'Joker 2019 1080p HCHDRip x264 - JusTiN.mkv']
[18:46:31] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie]
[18:46:31] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/movie/Joker']
[18:46:32] [INFO]::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
[18:46:32] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[18:46:32] [DEBUG]::MAIN: Found file Joker 2019 1080p HCHDRip x264 - JusTiN.mkv in root directory /volume1/downloads/movie.
[18:46:32] [INFO]::COPYLINK: MEDIAFILE: [b'Joker 2019 1080p HCHDRip x264 - JusTiN.mkv']
[18:46:32] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie]
[18:46:32] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/movie/Joker']
[18:46:32] [INFO]::COPYLINK: MEDIAFILE already exists in the TARGET folder, skipping ...
[18:46:32] [INFO]::MAIN: Starting manual run for Radarr:movie - Folder:/volume1/downloads/movie/Joker
[18:46:32] [INFO]::MAIN: Checking database for download info for Joker ...
[18:46:32] [DB]::DB: Getting download info for Joker from the DB
[18:46:32] [DB]::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['Joker', 0]
[18:46:32] [INFO]::MAIN: Unable to locate download info for Joker, continuing to try and process this release ...
[18:46:32] [DEBUG]::MAIN: Received Directory: /volume1/downloads/movie/Joker | Name: Joker | Category: movie
[18:46:32] [DEBUG]::MAIN: SEARCH: Found the Category: movie in directory structure
[18:46:32] [INFO]::MAIN: SEARCH: Found a unique directory Joker in the category directory
[18:46:32] [DEBUG]::MAIN: Determined Directory: /volume1/downloads/movie/Joker | Name: Joker | Category: movie
[18:46:32] [INFO]::MAIN: Auto-detected SECTION:Radarr
[18:46:32] [INFO]::MAIN: Output directory set to: /volume1/downloads/movie/Joker
[18:46:32] [DEBUG]::MAIN: Scanning files in directory: /volume1/downloads/movie/Joker
[18:46:32] [DEBUG]::MAIN: Found 1 files in /volume1/downloads/movie/Joker
[18:46:32] [INFO]::COPYLINK: MEDIAFILE: [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv]
[18:46:32] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/movie/Joker]
[18:46:32] [INFO]::COPYLINK: TARGET FOLDER: [/volume1/downloads/movie/Joker]
[18:46:32] [INFO]::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
[18:46:32] [DEBUG]::MAIN: Checking for archives to extract in directory: /volume1/downloads/movie/Joker
[18:46:32] [INFO]::MAIN: FLATTEN: Flattening directory: /volume1/downloads/movie/Joker
[18:46:32] [DEBUG]::MAIN: Checking for empty folders in:/volume1/downloads/movie/Joker
[18:46:32] [INFO]::MAIN: Found 1 media files in /volume1/downloads/movie/Joker
[18:46:32] [INFO]::MAIN: Calling Radarr:movie to post-process:Joker
[18:46:32] [INFO]::MAIN: Attemping imdbID lookup for Joker
[18:46:32] [INFO]::MAIN: Searching folder and file names for imdbID ...
[18:46:32] [INFO]::MAIN: Searching IMDB for imdbID ...
[18:46:32] [INFO]::MAIN: Unable to determine imdbID: No api key provided for ombdapi.com.
[18:46:32] [DEBUG]::SERVER: Attempting to connect to server at http://localhost:8310/api/command
[18:46:32] [DEBUG]::SERVER: Server responded at http://localhost:8310/api/command
[18:46:32] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
[18:46:34] [INFO]::TRANSCODER: Checking [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv] for corruption, please stand by ...
[18:46:34] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/movie/Joker/Joker 2019 1080p HCHDRip x264 - JusTiN.mkv
[18:46:34] [INFO]::TRANSCODER: SUCCESS: [Joker 2019 1080p HCHDRip x264 - JusTiN.mkv] has no corruption.
[18:46:34] [DEBUG]::RADARR: Opening URL: http://localhost:8310/api/command with PARAMS: {'importMode': 'Move', 'name': 'DownloadedMoviesScan', 'path': '/volume1/downloads/movie/Joker'}
[18:46:34] [POSTPROCESS]::RADARR: Starting DownloadedMoviesScan scan for Joker
[18:46:35] [POSTPROCESS]::POSTPROCESS: Radarr response: queued
[18:46:35] [DEBUG]::RADARR: Scan started with id: 361204
[18:46:35] [POSTPROCESS]::RADARR: Checking for status change, please stand by ...
[18:46:35] [DEBUG]::RADARR: The Scan command return status: started
[18:47:35] [POSTPROCESS]::RADARR: Checking for status change, please stand by ...
[18:47:35] [DEBUG]::RADARR: The Scan command return status: completed
[18:47:35] [DEBUG]::RADARR: The Scan command has completed successfully. Renaming was successful.
[18:47:35] [DEBUG]::PLEX: Attempting to update Plex Library for category movie.
[18:47:36] [DEBUG]::PLEX: Plex Library has been refreshed.
[18:47:36] [INFO]::CLEANDIR: Doing Forceful Clean of /volume1/downloads/movie/Joker
[18:47:36] [INFO]::MAIN: Deleting /volume1/downloads/movie/Joker
[18:47:36] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[18:47:36] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[18:47:36] [DEBUG]::MAIN: No directories identified in SickBeard:tv for post-processing
[18:47:36] [INFO]::MAIN: The ./TorrentToMedia.py script completed successfully.
clinton-hall commented 4 years ago

ok, the whole copylink thing shows that teh files are linked into their own unique (temp/staging) directory. The annoyance is that because you are doing a "manual" run (Downlaod station not fully supported) this does do the linking twice (but second time skips because it finds that the directory already exists). I will see if I can tidy this up, but it isn't actually a problem, just additional over-head in checking the file structure and logging.

So from what I'm seeing everything is working except for the deletion of the original torrent .

With this I note that the copyLink section is actually doing a HardLink but your config above shows

[Torrent]
      useLink = move

which should move the files (not hard-link) and therefore all cleanup should work fine... BUT... https://github.com/clinton-hall/nzbToMedia/blob/master/TorrentToMedia.py#L328 https://github.com/clinton-hall/nzbToMedia/blob/master/core/utils/common.py#L95 So when doing a manual Scan I use hard-linking as default to prevent accidental deletion!!!

So this all comes down to the need to receive details from Downlaod Station. as per this: https://github.com/clinton-hall/nzbToMedia/wiki/Download-Station Can you try

[Torrent]
    clientAgent = transmission

if this does now work, then that should fix all issues.

MrCee commented 4 years ago

Thanks Clinton. I last updated the https://github.com/clinton-hall/nzbToMedia/wiki/Download-Station wiki in 2016, and have since updated now, not a whole lot as changed at Synology's end but I will keep trying.

I believe that Synology's 'Download Station' is at the 90% mark of being supported, but it would require changes to your script, so I'm happy if anyone else with Synology DSM & python skills can go though the wiki as I'll bring this up to date as much as possible.

clinton-hall commented 4 years ago

Sorry about that. To be honest I didn't pay attention to who updated that... I just had a vague memory of it having been tested. Syno is one of a few platforms I haven't played with.

If 90% there, what isn't working? I.e can we receive directory, name, hash, category? Can we pause, start, remove?

clinton-hall commented 4 years ago

Ok, read your edits. So the key issue is the environment variable for torrent dir is not correct. Is there any other environment variable that DS uses instead, or can the actual path be passed as an arg? Or is there only 1 directory that we can put into the config?

clinton-hall commented 4 years ago

I just added a new synods clientAgent

[Torrent]
    clientAgent = synods

this is currently in SynoDS-patch-1 branch if you want to test...

based on guidance at https://forum.synology.com/enu/viewtopic.php?f=10&t=88918 and https://forum.synology.com/enu/viewtopic.php?f=38&t=92856 I am hoping this will make this work for you.... if it does, I'll merge up to nightly and eventually master... and you can add some more to the wiki :)

MrCee commented 4 years ago

@clinton-hall The TorrentToMedia.py script does run on the completion of each torrent when Download Station finishes but the temp location is parsed to the script.

On the exact moment of completion, the file is moved from the Synology temp directory + system generated number TR_TORRENT_ID e.g. /var/services/download/1010/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv to the completed download directory as set in SickChill / CouchPotato / Radarr or others. In this case the completed directory and file is /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv.

As you can see below, TorrentToMedia.py is grabbing the original environment temp location which does not contain tv or movie in the path, and at this stage (I believe before or at the same time the script runs), the file has already been moved.

So as Sickchill / CouchPotato / Radarr are able to specify the completed downloaded location and parse that to Download Station so the file can be post processed, in this case my SickChill setting is e.g. downloads/tv which is in my case /volume1/downloads/tv, there must be a way to query Download Station as to the final destination which you can see is set in the GUI when the torrent is added. Maybe?

2019-12-18 15:21:35 INFO    ::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
2019-12-18 15:21:36 INFO    ::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
2019-12-18 15:21:36 INFO    ::ENVIRONMENT: TR_TORRENT_NAME: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-18 15:21:36 INFO    ::ENVIRONMENT: TR_TORRENT_HASH: 8b8670b11c7950d0489244fee214f3d0bb124a99
2019-12-18 15:21:36 INFO    ::ENVIRONMENT: TR_APP_VERSION: 2.93
2019-12-18 15:21:36 INFO    ::ENVIRONMENT: TR_TIME_LOCALTIME: Wed Dec 18 15:21:13 2019
2019-12-18 15:21:36 INFO    ::ENVIRONMENT: TR_TORRENT_ID: 1010
2019-12-18 15:21:36 INFO    ::ENVIRONMENT: TR_TORRENT_DIR: /var/services/download/1010
2019-12-18 15:21:36 INFO    ::MAIN: Python v3.5 will reach end of life in 270 days.
2019-12-18 15:21:36 WARNING ::MAIN: Please upgrade to a more recent Python version.
2019-12-18 15:21:36 INFO    ::MAIN: Checking database structure...
2019-12-18 15:21:36 DEBUG   ::MAIN: Checking Initial Schema database upgrade
2019-12-18 15:21:36 DB      ::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
2019-12-18 15:21:36 DB      ::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
2019-12-18 15:21:36 DEBUG   ::MAIN: InitialSchema upgrade not required
2019-12-18 15:21:36 DEBUG   ::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
2019-12-18 15:21:36 DEBUG   ::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
2019-12-18 15:21:36 DEBUG   ::MAIN: git output: git version 2.15.1
2019-12-18 15:21:36 DEBUG   ::MAIN: "/usr/local/bin/git" version : returned successful
2019-12-18 15:21:36 DEBUG   ::MAIN: Using: "/usr/local/bin/git"
2019-12-18 15:21:36 DEBUG   ::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-18 15:21:36 DEBUG   ::MAIN: git output: refs/heads/SynoDS-patch-1
2019-12-18 15:21:36 DEBUG   ::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
2019-12-18 15:21:36 INFO    ::MAIN: Checking if git needs an update
2019-12-18 15:21:36 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-18 15:21:36 DEBUG   ::MAIN: git output: 3a4efdb53c4b106c50d4458f0c8a5a0af60970f0
2019-12-18 15:21:36 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
2019-12-18 15:21:36 DEBUG   ::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
2019-12-18 15:21:39 DEBUG   ::MAIN: git output:
2019-12-18 15:21:39 DEBUG   ::MAIN: "/usr/local/bin/git" fetch origin : returned successful
2019-12-18 15:21:39 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
2019-12-18 15:21:39 DEBUG   ::MAIN: git output: 5b4fb520df001c82b754aeae442f17e38ab57f0f
2019-12-18 15:21:39 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
2019-12-18 15:21:39 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-18 15:21:39 DEBUG   ::MAIN: git output: >3a4efdb53c4b106c50d4458f0c8a5a0af60970f0
>4e41595038315e654184f321b0a1f65118f5db4a
>8e22f228fbc4f4d466fcf1d958541640d6d71f1b
>e386393bf2f8e5e9a92c2c2226b401ec02b82ff7
2019-12-18 15:21:39 DEBUG   ::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2019-12-18 15:21:39 DEBUG   ::MAIN: cur_commit = 3a4efdb53c4b106c50d4458f0c8a5a0af60970f0 % (newest_commit)= 5b4fb520df001c82b754aeae442f17e38ab57f0f, num_commits_behind = 0, num_commits_ahead = 4
2019-12-18 15:21:39 INFO    ::MAIN: No update needed
2019-12-18 15:21:39 INFO    ::MAIN: nzbToMedia Version:3a4efdb53c4b106c50d4458f0c8a5a0af60970f0 Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-18 15:21:41 INFO    ::MAIN: #########################################################
2019-12-18 15:21:41 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-18 15:21:41 INFO    ::MAIN: #########################################################
2019-12-18 15:21:41 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2019-12-18 15:21:41 DEBUG   ::MAIN: Adding TORRENT download info for directory /var/services/download/1010/../Vikings.S06E01.HDTV.x264-SVA[eztv].mkv to database
2019-12-18 15:21:41 DB      ::MAIN: nzbtomedia.db: UPDATE downloads SET status = ?, last_update = ?, input_id = ?, client_agent = ?, input_name = ?, input_hash = ? WHERE input_directory = ? with args [0$
2019-12-18 15:21:41 DB      ::MAIN: nzbtomedia.db: INSERT OR IGNORE INTO downloads (status, last_update, input_id, client_agent, input_name, input_hash) VALUES (?, ?, ?, ?, ?, ?) with args [0, 737411, '$
2019-12-18 15:21:41 DEBUG   ::MAIN: Received Directory: /var/services/download/1010/../Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category:
2019-12-18 15:21:41 DEBUG   ::MAIN: SEARCH: Could not find a category in the directory structure
2019-12-18 15:21:41 INFO    ::MAIN: SEARCH: Found torrent directory Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in the directory structure
2019-12-18 15:21:41 DEBUG   ::MAIN: Determined Directory: /var/services/download/1010/../Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category: UNCAT
2019-12-18 15:21:41 ERROR   ::MAIN: Unable to locate a section with subsection:UNCAT enabled in your autoProcessMedia.cfg, exiting!
clinton-hall commented 4 years ago

ok... so this SHOULD use the synology api

https://github.com/clinton-hall/nzbToMedia/commit/a8d7f85544d79c876b961bd7add72388b1ef9368

the problem here is that I have no way of testing, so it is completely theoretical, and assumes that the TR_TORRENT_ID: 1010 does match the task_id used in the downloadstation api.

also, here https://github.com/clinton-hall/nzbToMedia/blob/a8d7f85544d79c876b961bd7add72388b1ef9368/core/utils/parsers.py#L91-L92 I am assuming that this is the correct syntax to parse the results returned from the api... again no way of testing.

To enable this, update the latest SynoDS-patch-1 branch and set

[Torrent]
    clientAgent = synods
    synoHost = localhost
    synoPort = <synology interface port>
    synoUSR =<syno username>
    synoPWD = <syno password>

this is based on https://github.com/N4S4/synology-api with reference to https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/DownloadStation/All/enu/Synology_Download_Station_Web_API.pdf

MrCee commented 4 years ago

@clinton-hall

Making progress, I believe I get a connection to Download Station using synoPort = 5000. Any other port would show ERROR ::MAIN: Failed to connect to synology in the log.

Although it switches to manual run mode, I probably require help debugging Invalid number of arguments received from client on Synology Download Station at my end.

2019-12-20 13:25:19 INFO    ::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
2019-12-20 13:25:19 INFO    ::ENVIRONMENT: TR_TIME_LOCALTIME: Fri Dec 20 13:24:53 2019
2019-12-20 13:25:19 INFO    ::ENVIRONMENT: TR_APP_VERSION: 2.93
2019-12-20 13:25:19 INFO    ::ENVIRONMENT: TR_TORRENT_NAME: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-20 13:25:19 INFO    ::ENVIRONMENT: TR_TORRENT_HASH: 8b8670b11c7950d0489244fee214f3d0bb124a99
2019-12-20 13:25:19 INFO    ::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
2019-12-20 13:25:19 INFO    ::ENVIRONMENT: TR_TORRENT_DIR: /var/services/download/1028
2019-12-20 13:25:19 INFO    ::ENVIRONMENT: TR_TORRENT_ID: 1028
2019-12-20 13:25:19 INFO    ::MAIN: Python v3.5 will reach end of life in 268 days.
2019-12-20 13:25:19 WARNING ::MAIN: Please upgrade to a more recent Python version.
2019-12-20 13:25:19 INFO    ::MAIN: Checking database structure...
2019-12-20 13:25:19 DEBUG   ::MAIN: Checking Initial Schema database upgrade
2019-12-20 13:25:19 DB      ::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
2019-12-20 13:25:19 DB      ::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
2019-12-20 13:25:19 DEBUG   ::MAIN: InitialSchema upgrade not required
2019-12-20 13:25:19 DEBUG   ::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
2019-12-20 13:25:19 DEBUG   ::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
2019-12-20 13:25:19 DEBUG   ::MAIN: git output: git version 2.15.1
2019-12-20 13:25:19 DEBUG   ::MAIN: "/usr/local/bin/git" version : returned successful
2019-12-20 13:25:19 DEBUG   ::MAIN: Using: "/usr/local/bin/git"
2019-12-20 13:25:19 DEBUG   ::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-20 13:25:19 DEBUG   ::MAIN: git output: refs/heads/SynoDS-patch-1
2019-12-20 13:25:19 DEBUG   ::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
2019-12-20 13:25:19 INFO    ::MAIN: Checking if git needs an update
2019-12-20 13:25:19 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-20 13:25:20 DEBUG   ::MAIN: git output: fe6391a95ac6282e9bf8d80b1a7a4d8ebd02699d
2019-12-20 13:25:20 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
2019-12-20 13:25:20 DEBUG   ::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
2019-12-20 13:25:23 DEBUG   ::MAIN: git output: 
2019-12-20 13:25:23 DEBUG   ::MAIN: "/usr/local/bin/git" fetch origin : returned successful
2019-12-20 13:25:23 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
2019-12-20 13:25:23 DEBUG   ::MAIN: git output: a8d7f85544d79c876b961bd7add72388b1ef9368
2019-12-20 13:25:23 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
2019-12-20 13:25:23 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-20 13:25:23 DEBUG   ::MAIN: git output: >fe6391a95ac6282e9bf8d80b1a7a4d8ebd02699d
>3a4efdb53c4b106c50d4458f0c8a5a0af60970f0
>4e41595038315e654184f321b0a1f65118f5db4a
>8e22f228fbc4f4d466fcf1d958541640d6d71f1b
>e386393bf2f8e5e9a92c2c2226b401ec02b82ff7
2019-12-20 13:25:23 DEBUG   ::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2019-12-20 13:25:23 DEBUG   ::MAIN: cur_commit = fe6391a95ac6282e9bf8d80b1a7a4d8ebd02699d % (newest_commit)= a8d7f85544d79c876b961bd7add72388b1ef9368, num_commits_behind = 0, num_commits_ahead = 5
2019-12-20 13:25:23 INFO    ::MAIN: No update needed
2019-12-20 13:25:23 INFO    ::MAIN: nzbToMedia Version:fe6391a95ac6282e9bf8d80b1a7a4d8ebd02699d Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-20 13:25:24 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2019-12-20 13:25:27 INFO    ::MAIN: #########################################################
2019-12-20 13:25:27 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-20 13:25:27 INFO    ::MAIN: #########################################################
2019-12-20 13:25:27 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2019-12-20 13:25:28 WARNING ::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
2019-12-20 13:25:28 INFO    ::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
2019-12-20 13:25:28 INFO    ::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
2019-12-20 13:25:28 DEBUG   ::MAIN: No directories identified in Radarr:movie for post-processing
2019-12-20 13:25:28 INFO    ::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
2019-12-20 13:25:28 DEBUG   ::MAIN: Found file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in root directory /volume1/downloads/tv.
2019-12-20 13:25:30 INFO    ::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv']
2019-12-20 13:25:30 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
2019-12-20 13:25:30 INFO    ::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
2019-12-20 13:25:30 INFO    ::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
2019-12-20 13:25:30 INFO    ::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
2019-12-20 13:25:30 DEBUG   ::MAIN: Found file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in root directory /volume1/downloads/tv.
2019-12-20 13:25:31 INFO    ::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv']
2019-12-20 13:25:31 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
2019-12-20 13:25:31 INFO    ::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
2019-12-20 13:25:31 INFO    ::COPYLINK: MEDIAFILE already exists in the TARGET folder, skipping ...
2019-12-20 13:25:31 INFO    ::MAIN: Starting manual run for SickBeard:tv - Folder:/volume1/downloads/tv/Vikings
2019-12-20 13:25:31 INFO    ::MAIN: Checking database for download info for Vikings ...
2019-12-20 13:25:31 DB      ::DB: Getting download info for Vikings from the DB
2019-12-20 13:25:31 DB      ::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['Vikings', 0]
2019-12-20 13:25:31 INFO    ::MAIN: Unable to locate download info for Vikings, continuing to try and process this release ...
2019-12-20 13:25:31 DEBUG   ::MAIN: Received Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
2019-12-20 13:25:31 DEBUG   ::MAIN: SEARCH: Found the Category: tv in directory structure
2019-12-20 13:25:31 INFO    ::MAIN: SEARCH: Found a unique directory Vikings in the category directory
2019-12-20 13:25:31 DEBUG   ::MAIN: Determined Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
2019-12-20 13:25:31 INFO    ::MAIN: Auto-detected SECTION:SickBeard
2019-12-20 13:25:31 INFO    ::MAIN: Output directory set to: /volume1/downloads/tv/Vikings
2019-12-20 13:25:31 DEBUG   ::MAIN: Scanning files in directory: /volume1/downloads/tv/Vikings
2019-12-20 13:25:31 DEBUG   ::MAIN: Found 1 files in /volume1/downloads/tv/Vikings
2019-12-20 13:25:31 INFO    ::COPYLINK: MEDIAFILE: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv]
2019-12-20 13:25:31 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv/Vikings]
2019-12-20 13:25:31 INFO    ::COPYLINK: TARGET FOLDER: [/volume1/downloads/tv/Vikings]
2019-12-20 13:25:31 INFO    ::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
2019-12-20 13:25:31 DEBUG   ::MAIN: Checking for archives to extract in directory: /volume1/downloads/tv/Vikings
2019-12-20 13:25:31 INFO    ::MAIN: FLATTEN: Flattening directory: /volume1/downloads/tv/Vikings
2019-12-20 13:25:31 DEBUG   ::MAIN: Checking for empty folders in:/volume1/downloads/tv/Vikings
2019-12-20 13:25:31 INFO    ::MAIN: Found 1 media files in /volume1/downloads/tv/Vikings
2019-12-20 13:25:31 INFO    ::MAIN: Calling SickBeard:tv to post-process:Vikings
2019-12-20 13:25:31 INFO    ::MAIN: Changing file mode of /volume1/downloads/tv/Vikings to 0o777
2019-12-20 13:25:31 DEBUG   ::SERVER: Attempting to connect to server at http://localhost:8083
2019-12-20 13:25:37 DEBUG   ::SERVER: Server responded at http://localhost:8083
2019-12-20 13:25:37 INFO    ::MAIN: SickBeard:tv fork set to SickChill
2019-12-20 13:25:37 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
2019-12-20 13:25:38 INFO    ::TRANSCODER: Checking [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] for corruption, please stand by ...
2019-12-20 13:25:38 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/tv/Vikings/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-20 13:25:38 INFO    ::TRANSCODER: SUCCESS: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] has no corruption.
2019-12-20 13:25:38 POSTPROCESS::SICKBEARD: SUCCESS: The download succeeded, sending a post-process request
2019-12-20 13:25:38 DEBUG   ::SICKBEARD: Opening URL: http://localhost:8083/api/be87600ad695b39a8071fa6a4851f8ad/?cmd=postprocess with params: {'proc_dir': '/volume1/downloads/tv/Vikings', 'force_next': 1, 'nzbName': 'Vikings', 'delete_on': 1, 'process_method': 'move', 'quiet': 1, 'failed': 0}
2019-12-20 13:26:05 DEBUG   ::PLEX: Attempting to update Plex Library for category tv.
2019-12-20 13:26:06 DEBUG   ::PLEX: Plex Library has been refreshed.
2019-12-20 13:26:06 INFO    ::CLEANDIR: Directory /volume1/downloads/tv/Vikings has been processed and removed ...
2019-12-20 13:26:06 INFO    ::MAIN: The /volume1/@appstore/nzbToMedia/TorrentToMedia.py script completed successfully.
clinton-hall commented 4 years ago

ok, I just made a small change to remove a "try". This won't fix the issue, but should print an error log/traceback to show what went wrong.

can you update, try again, and post the error?

MrCee commented 4 years ago

@clinton-hall

Here's the log:

2019-12-22 14:52:54 INFO    ::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
2019-12-22 14:52:54 INFO    ::ENVIRONMENT: TR_TORRENT_HASH: 8b8670b11c7950d0489244fee214f3d0bb124a99
2019-12-22 14:52:54 INFO    ::ENVIRONMENT: TR_TIME_LOCALTIME: Sun Dec 22 14:52:32 2019
2019-12-22 14:52:54 INFO    ::ENVIRONMENT: TR_TORRENT_DIR: /var/services/download/1039
2019-12-22 14:52:54 INFO    ::ENVIRONMENT: TR_TORRENT_ID: 1039
2019-12-22 14:52:54 INFO    ::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
2019-12-22 14:52:54 INFO    ::ENVIRONMENT: TR_APP_VERSION: 2.93
2019-12-22 14:52:54 INFO    ::ENVIRONMENT: TR_TORRENT_NAME: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-22 14:52:54 INFO    ::MAIN: Python v3.5 will reach end of life in 266 days.
2019-12-22 14:52:54 WARNING ::MAIN: Please upgrade to a more recent Python version.
2019-12-22 14:52:54 INFO    ::MAIN: Checking database structure...
2019-12-22 14:52:54 DEBUG   ::MAIN: Checking Initial Schema database upgrade
2019-12-22 14:52:54 DB      ::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
2019-12-22 14:52:54 DB      ::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
2019-12-22 14:52:54 DEBUG   ::MAIN: InitialSchema upgrade not required
2019-12-22 14:52:54 DEBUG   ::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
2019-12-22 14:52:54 DEBUG   ::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 14:52:54 DEBUG   ::MAIN: git output: git version 2.15.1
2019-12-22 14:52:54 DEBUG   ::MAIN: "/usr/local/bin/git" version : returned successful
2019-12-22 14:52:54 DEBUG   ::MAIN: Using: "/usr/local/bin/git"
2019-12-22 14:52:54 DEBUG   ::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 14:52:54 DEBUG   ::MAIN: git output: refs/heads/SynoDS-patch-1
2019-12-22 14:52:54 DEBUG   ::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
2019-12-22 14:52:54 INFO    ::MAIN: Checking if git needs an update
2019-12-22 14:52:54 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 14:52:54 DEBUG   ::MAIN: git output: b2a2364cdee6372443f3d845ff0567608986f91a
2019-12-22 14:52:54 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
2019-12-22 14:52:54 DEBUG   ::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 14:52:59 DEBUG   ::MAIN: git output:
2019-12-22 14:52:59 DEBUG   ::MAIN: "/usr/local/bin/git" fetch origin : returned successful
2019-12-22 14:52:59 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 14:52:59 DEBUG   ::MAIN: git output: f3459fb252b46b386720c6602ff05cac91f713ee
2019-12-22 14:52:59 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
2019-12-22 14:52:59 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 14:52:59 DEBUG   ::MAIN: git output: >b2a2364cdee6372443f3d845ff0567608986f91a
>fe6391a95ac6282e9bf8d80b1a7a4d8ebd02699d
>3a4efdb53c4b106c50d4458f0c8a5a0af60970f0
>4e41595038315e654184f321b0a1f65118f5db4a
>8e22f228fbc4f4d466fcf1d958541640d6d71f1b
>e386393bf2f8e5e9a92c2c2226b401ec02b82ff7
2019-12-22 14:52:59 DEBUG   ::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2019-12-22 14:52:59 DEBUG   ::MAIN: cur_commit = b2a2364cdee6372443f3d845ff0567608986f91a % (newest_commit)= f3459fb252b46b386720c6602ff05cac91f713ee, num_commits_behind = 0, num_commits_ahead = 6
2019-12-22 14:52:59 INFO    ::MAIN: No update needed
2019-12-22 14:52:59 INFO    ::MAIN: nzbToMedia Version:b2a2364cdee6372443f3d845ff0567608986f91a Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-22 14:53:00 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2019-12-22 14:53:03 INFO    ::MAIN: #########################################################
2019-12-22 14:53:03 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-22 14:53:03 INFO    ::MAIN: #########################################################
2019-12-22 14:53:03 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2019-12-22 14:53:04 ERROR   ::MAIN: There was a problem loading variables
clinton-hall commented 4 years ago

darn, I had more error handing.

are you able to update and try again. Until I see what the error is, I can't try to fix it.

MrCee commented 4 years ago

@clinton-hall Not much happened this time. I have tried twice and we are stuck at DEBUG ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']

2019-12-22 20:57:20 INFO    ::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
2019-12-22 20:57:20 INFO    ::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
2019-12-22 20:57:20 INFO    ::ENVIRONMENT: TR_TIME_LOCALTIME: Sun Dec 22 20:56:59 2019
2019-12-22 20:57:20 INFO    ::ENVIRONMENT: TR_TORRENT_DIR: /var/services/download/1040
2019-12-22 20:57:20 INFO    ::ENVIRONMENT: TR_TORRENT_NAME: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-22 20:57:20 INFO    ::ENVIRONMENT: TR_TORRENT_HASH: 8b8670b11c7950d0489244fee214f3d0bb124a99
2019-12-22 20:57:20 INFO    ::ENVIRONMENT: TR_APP_VERSION: 2.93
2019-12-22 20:57:20 INFO    ::ENVIRONMENT: TR_TORRENT_ID: 1040
2019-12-22 20:57:20 INFO    ::MAIN: Python v3.5 will reach end of life in 266 days.
2019-12-22 20:57:20 WARNING ::MAIN: Please upgrade to a more recent Python version.
2019-12-22 20:57:20 INFO    ::MAIN: Checking database structure...
2019-12-22 20:57:20 DEBUG   ::MAIN: Checking Initial Schema database upgrade
2019-12-22 20:57:20 DB      ::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
2019-12-22 20:57:20 DB      ::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
2019-12-22 20:57:20 DEBUG   ::MAIN: InitialSchema upgrade not required
2019-12-22 20:57:20 DEBUG   ::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
2019-12-22 20:57:20 DEBUG   ::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 20:57:20 DEBUG   ::MAIN: git output: git version 2.15.1
2019-12-22 20:57:20 DEBUG   ::MAIN: "/usr/local/bin/git" version : returned successful
2019-12-22 20:57:20 DEBUG   ::MAIN: Using: "/usr/local/bin/git"
2019-12-22 20:57:20 DEBUG   ::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 20:57:20 DEBUG   ::MAIN: git output: refs/heads/SynoDS-patch-1
2019-12-22 20:57:20 DEBUG   ::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
2019-12-22 20:57:20 INFO    ::MAIN: Checking if git needs an update
2019-12-22 20:57:20 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 20:57:20 DEBUG   ::MAIN: git output: e4cc7c91218175adbab34abd103f42587ca07035
2019-12-22 20:57:20 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
2019-12-22 20:57:20 DEBUG   ::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 20:57:25 DEBUG   ::MAIN: git output:
2019-12-22 20:57:25 DEBUG   ::MAIN: "/usr/local/bin/git" fetch origin : returned successful
2019-12-22 20:57:25 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 20:57:25 DEBUG   ::MAIN: git output: 189b1a487eddd7a610d57cf4b2ce8a857820d55f
2019-12-22 20:57:25 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
2019-12-22 20:57:25 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-22 20:57:25 DEBUG   ::MAIN: git output: >e4cc7c91218175adbab34abd103f42587ca07035
>b2a2364cdee6372443f3d845ff0567608986f91a
>fe6391a95ac6282e9bf8d80b1a7a4d8ebd02699d
>3a4efdb53c4b106c50d4458f0c8a5a0af60970f0
>4e41595038315e654184f321b0a1f65118f5db4a
>8e22f228fbc4f4d466fcf1d958541640d6d71f1b
>e386393bf2f8e5e9a92c2c2226b401ec02b82ff7
2019-12-22 20:57:25 DEBUG   ::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2019-12-22 20:57:25 DEBUG   ::MAIN: cur_commit = e4cc7c91218175adbab34abd103f42587ca07035 % (newest_commit)= 189b1a487eddd7a610d57cf4b2ce8a857820d55f, num_commits_behind = 0, num_commits_ahead = 7
2019-12-22 20:57:25 INFO    ::MAIN: No update needed
2019-12-22 20:57:25 INFO    ::MAIN: nzbToMedia Version:e4cc7c91218175adbab34abd103f42587ca07035 Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-22 20:57:26 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2019-12-22 20:57:29 INFO    ::MAIN: #########################################################
2019-12-22 20:57:29 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-22 20:57:29 INFO    ::MAIN: #########################################################
2019-12-22 20:57:29 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
MrCee commented 4 years ago

@clinton-hall Additionally to the last post, I just tested a manual run... looks like there is something that needs to be fixed for this scenario also.

[13:45:13] [DEBUG]::MAIN: Connecting to synology: http://localhost:5000
You are now logged in!
[13:45:17] [INFO]::MAIN: #########################################################
[13:45:17] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[13:45:17] [INFO]::MAIN: #########################################################
[13:45:17] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['./TorrentToMedia.py']
Traceback (most recent call last):
  File "./TorrentToMedia.py", line 370, in <module>
    exit(main(sys.argv))
  File "./TorrentToMedia.py", line 313, in main
    input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args)
  File "/volume1/@appstore/nzbToMedia/core/utils/parsers.py", line 178, in parse_args
    return clients[client_agent](args)
  File "/volume1/@appstore/nzbToMedia/core/utils/parsers.py", line 92, in parse_synods
    input_directory = res.json()['tasks'][0]['additional']['detail']['destination']
AttributeError: 'dict' object has no attribute 'json'
clinton-hall commented 4 years ago

thanks... that's what I needed to see...

I have removed the json. and that error at least confirms that a 'dict' object was returned from Syno DS.

if you could update to latest and then try again... I'm hoping this works now, or at least another manual run will give more meaningful errors like the last :)

MrCee commented 4 years ago

@clinton-hall So this is a manual run result after update:

[18:21:01] [DEBUG]::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
[18:21:01] [DEBUG]::MAIN: cur_commit = 3085056277cae99a10fe883c8b6b5fdf3d34fff5 % (newest_commit)= b9435e85b11d9174469c5b1735b936970d17a639, num_commits_behind = 0, num_commits_ahead = 8
[18:21:01] [INFO]::MAIN: No update needed
[18:21:01] [INFO]::MAIN: nzbToMedia Version:3085056277cae99a10fe883c8b6b5fdf3d34fff5 Branch:SynoDS-patch-1 (Linux 3.2.40)
[18:21:02] [DEBUG]::MAIN: Connecting to synology: http://localhost:5000
You are now logged in!
[18:21:06] [INFO]::MAIN: #########################################################
[18:21:06] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[18:21:06] [INFO]::MAIN: #########################################################
[18:21:06] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['./TorrentToMedia.py']
Traceback (most recent call last):
  File "./TorrentToMedia.py", line 370, in <module>
    exit(main(sys.argv))
  File "./TorrentToMedia.py", line 313, in main
    input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args)
  File "/volume1/@appstore/nzbToMedia/core/utils/parsers.py", line 178, in parse_args
    return clients[client_agent](args)
  File "/volume1/@appstore/nzbToMedia/core/utils/parsers.py", line 92, in parse_synods
    input_directory = res['tasks'][0]['additional']['detail']['destination']
KeyError: 'tasks'

And this is the automated Synology Download Station triggered run result after update:

2019-12-23 18:50:21 DEBUG   ::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2019-12-23 18:50:21 DEBUG   ::MAIN: cur_commit = 3085056277cae99a10fe883c8b6b5fdf3d34fff5 % (newest_commit)= b9435e85b11d9174469c5b1735b936970d17a639, num_commits_behind = 0, num_commits_ahead = 8
2019-12-23 18:50:21 INFO    ::MAIN: No update needed
2019-12-23 18:50:21 INFO    ::MAIN: nzbToMedia Version:3085056277cae99a10fe883c8b6b5fdf3d34fff5 Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-23 18:50:22 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2019-12-23 18:50:26 INFO    ::MAIN: #########################################################
2019-12-23 18:50:26 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-23 18:50:26 INFO    ::MAIN: #########################################################
2019-12-23 18:50:26 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
clinton-hall commented 4 years ago

I'm so sorry for all this... I checked again against the syno api docs and the example results they provide work for me.... so I am assuming their documentation is incorrect (changed version) and therefore I can only do this by printing the return code to the log...

I have done this now, so if you update to latest and run, the log should show the data returned by syno.... this should then allow us to determine how this needs to be parsed to get the directory.

MrCee commented 4 years ago

@clinton-hall It's no problem at all. All good.

Here's the manual run result:

[20:58:56] [DEBUG]::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
[20:58:56] [DEBUG]::MAIN: cur_commit = f76ed0a0f3c9ede3a89902131be6909faf7c0fe2 % (newest_commit)= f0f64b052e92babf14b8d97ecd621cdb048749ed, num_commits_behind = 0, num_commits_ahead = 9
[20:58:56] [INFO]::MAIN: No update needed
[20:58:56] [INFO]::MAIN: nzbToMedia Version:f76ed0a0f3c9ede3a89902131be6909faf7c0fe2 Branch:SynoDS-patch-1 (Linux 3.2.40)
[20:58:56] [DEBUG]::MAIN: Connecting to synology: http://localhost:5000
You are now logged in!
[20:59:00] [INFO]::MAIN: #########################################################
[20:59:00] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[20:59:00] [INFO]::MAIN: #########################################################
[20:59:00] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['./TorrentToMedia.py']
[20:59:01] [ERROR]::MAIN: result keys are dict_keys(['success', 'data'])
[20:59:01] [INFO]::MAIN: result from syno {'success': True, 'data': {'tasks': [{'status': 'error'}]}}
[20:59:01] [WARNING]::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
[20:59:01] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[20:59:01] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[20:59:01] [DEBUG]::MAIN: No directories identified in Radarr:movie for post-processing
[20:59:01] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[20:59:01] [DEBUG]::MAIN: Found file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in root directory /volume1/downloads/tv.
[20:59:03] [INFO]::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv']
[20:59:03] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
[20:59:03] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
[20:59:03] [INFO]::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
[20:59:03] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[20:59:03] [DEBUG]::MAIN: Found file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in root directory /volume1/downloads/tv.
[20:59:03] [INFO]::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv']
[20:59:03] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
[20:59:03] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
[20:59:03] [INFO]::COPYLINK: MEDIAFILE already exists in the TARGET folder, skipping ...
[20:59:03] [INFO]::MAIN: Starting manual run for SickBeard:tv - Folder:/volume1/downloads/tv/Vikings
[20:59:03] [INFO]::MAIN: Checking database for download info for Vikings ...
[20:59:03] [DB]::DB: Getting download info for Vikings from the DB
[20:59:03] [DB]::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['Vikings', 0]
[20:59:03] [INFO]::MAIN: Unable to locate download info for Vikings, continuing to try and process this release ...
[20:59:03] [DEBUG]::MAIN: Received Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
[20:59:03] [DEBUG]::MAIN: SEARCH: Found the Category: tv in directory structure
[20:59:03] [INFO]::MAIN: SEARCH: Found a unique directory Vikings in the category directory
[20:59:03] [DEBUG]::MAIN: Determined Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
[20:59:03] [INFO]::MAIN: Auto-detected SECTION:SickBeard
[20:59:03] [INFO]::MAIN: Output directory set to: /volume1/downloads/tv/Vikings
[20:59:03] [DEBUG]::MAIN: Scanning files in directory: /volume1/downloads/tv/Vikings
[20:59:03] [DEBUG]::MAIN: Found 1 files in /volume1/downloads/tv/Vikings
[20:59:03] [INFO]::COPYLINK: MEDIAFILE: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv]
[20:59:03] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv/Vikings]
[20:59:03] [INFO]::COPYLINK: TARGET FOLDER: [/volume1/downloads/tv/Vikings]
[20:59:03] [INFO]::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
[20:59:03] [DEBUG]::MAIN: Checking for archives to extract in directory: /volume1/downloads/tv/Vikings
[20:59:03] [INFO]::MAIN: FLATTEN: Flattening directory: /volume1/downloads/tv/Vikings
[20:59:03] [DEBUG]::MAIN: Checking for empty folders in:/volume1/downloads/tv/Vikings
[20:59:03] [INFO]::MAIN: Found 1 media files in /volume1/downloads/tv/Vikings
[20:59:03] [INFO]::MAIN: Calling SickBeard:tv to post-process:Vikings
[20:59:03] [INFO]::MAIN: Changing file mode of /volume1/downloads/tv/Vikings to 0o777
[20:59:03] [DEBUG]::SERVER: Attempting to connect to server at http://localhost:8083
[20:59:06] [DEBUG]::SERVER: Server responded at http://localhost:8083
[20:59:06] [INFO]::MAIN: SickBeard:tv fork set to SickChill
[20:59:06] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
[20:59:07] [INFO]::TRANSCODER: Checking [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] for corruption, please stand by ...
[20:59:07] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/tv/Vikings/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
[20:59:07] [INFO]::TRANSCODER: SUCCESS: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] has no corruption.
[20:59:07] [POSTPROCESS]::SICKBEARD: SUCCESS: The download succeeded, sending a post-process request
[20:59:07] [DEBUG]::SICKBEARD: Opening URL: http://localhost:8083/api/be87600ad695b39a8071fa6a4851f8ad/?cmd=postprocess with params: {'delete_on': 1, 'nzbName': 'Vikings', 'force_next': 1, 'proc_dir': '/volume1/downloads/tv/Vikings', 'process_method': 'move', 'failed': 0, 'quiet': 1}
[20:59:21] [DEBUG]::PLEX: Attempting to update Plex Library for category tv.
[20:59:21] [DEBUG]::PLEX: Plex Library has been refreshed.
[20:59:21] [INFO]::CLEANDIR: Directory /volume1/downloads/tv/Vikings has been processed and removed ...
[20:59:21] [INFO]::MAIN: The ./TorrentToMedia.py script completed successfully.

Here's the Synology Download Station triggered result: (it's missing the You are now logged in! in the log this time)

2019-12-23 21:09:23 DEBUG   ::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2019-12-23 21:09:23 DEBUG   ::MAIN: cur_commit = f76ed0a0f3c9ede3a89902131be6909faf7c0fe2 % (newest_commit)= f0f64b052e92babf14b8d97ecd621cdb048749ed, num_commits_behind = 0, num_commits_ahead = 9
2019-12-23 21:09:23 INFO    ::MAIN: No update needed
2019-12-23 21:09:23 INFO    ::MAIN: nzbToMedia Version:f76ed0a0f3c9ede3a89902131be6909faf7c0fe2 Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-23 21:09:24 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2019-12-23 21:09:28 INFO    ::MAIN: #########################################################
2019-12-23 21:09:28 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-23 21:09:28 INFO    ::MAIN: #########################################################
2019-12-23 21:09:28 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2019-12-23 21:09:29 ERROR   ::MAIN: result keys are dict_keys(['success', 'error'])
2019-12-23 21:09:29 INFO    ::MAIN: result from syno {'success': False, 'error': {'code': 101}}
2019-12-23 21:09:29 WARNING ::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
2019-12-23 21:09:29 INFO    ::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
2019-12-23 21:09:29 INFO    ::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
2019-12-23 21:09:29 DEBUG   ::MAIN: No directories identified in Radarr:movie for post-processing
2019-12-23 21:09:29 INFO    ::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
2019-12-23 21:09:29 DEBUG   ::MAIN: Found file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in root directory /volume1/downloads/tv.
2019-12-23 21:09:31 INFO    ::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv']
2019-12-23 21:09:31 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
2019-12-23 21:09:31 INFO    ::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
2019-12-23 21:09:31 INFO    ::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
2019-12-23 21:09:31 INFO    ::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
2019-12-23 21:09:31 DEBUG   ::MAIN: Found file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in root directory /volume1/downloads/tv.
2019-12-23 21:09:31 INFO    ::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv']
2019-12-23 21:09:31 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
2019-12-23 21:09:31 INFO    ::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
2019-12-23 21:09:31 INFO    ::COPYLINK: MEDIAFILE already exists in the TARGET folder, skipping ...
2019-12-23 21:09:31 INFO    ::MAIN: Starting manual run for SickBeard:tv - Folder:/volume1/downloads/tv/Vikings
2019-12-23 21:09:31 INFO    ::MAIN: Checking database for download info for Vikings ...
2019-12-23 21:09:31 DB      ::DB: Getting download info for Vikings from the DB
2019-12-23 21:09:31 DB      ::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['Vikings', 0]
2019-12-23 21:09:31 INFO    ::MAIN: Unable to locate download info for Vikings, continuing to try and process this release ...
2019-12-23 21:09:31 DEBUG   ::MAIN: Received Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
2019-12-23 21:09:31 DEBUG   ::MAIN: SEARCH: Found the Category: tv in directory structure
2019-12-23 21:09:31 INFO    ::MAIN: SEARCH: Found a unique directory Vikings in the category directory
2019-12-23 21:09:31 DEBUG   ::MAIN: Determined Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
2019-12-23 21:09:31 INFO    ::MAIN: Auto-detected SECTION:SickBeard
2019-12-23 21:09:31 INFO    ::MAIN: Output directory set to: /volume1/downloads/tv/Vikings
2019-12-23 21:09:31 DEBUG   ::MAIN: Scanning files in directory: /volume1/downloads/tv/Vikings
2019-12-23 21:09:31 DEBUG   ::MAIN: Found 1 files in /volume1/downloads/tv/Vikings
2019-12-23 21:09:31 INFO    ::COPYLINK: MEDIAFILE: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv]
2019-12-23 21:09:31 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv/Vikings]
2019-12-23 21:09:31 INFO    ::COPYLINK: TARGET FOLDER: [/volume1/downloads/tv/Vikings]
2019-12-23 21:09:31 INFO    ::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
2019-12-23 21:09:31 DEBUG   ::MAIN: Checking for archives to extract in directory: /volume1/downloads/tv/Vikings
2019-12-23 21:09:31 INFO    ::MAIN: FLATTEN: Flattening directory: /volume1/downloads/tv/Vikings
2019-12-23 21:09:31 DEBUG   ::MAIN: Checking for empty folders in:/volume1/downloads/tv/Vikings
2019-12-23 21:09:31 INFO    ::MAIN: Found 1 media files in /volume1/downloads/tv/Vikings
2019-12-23 21:09:31 INFO    ::MAIN: Calling SickBeard:tv to post-process:Vikings
2019-12-23 21:09:31 INFO    ::MAIN: Changing file mode of /volume1/downloads/tv/Vikings to 0o777
2019-12-23 21:09:31 DEBUG   ::SERVER: Attempting to connect to server at http://localhost:8083
2019-12-23 21:09:33 DEBUG   ::SERVER: Server responded at http://localhost:8083
2019-12-23 21:09:33 INFO    ::MAIN: SickBeard:tv fork set to SickChill
2019-12-23 21:09:33 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
2019-12-23 21:09:34 INFO    ::TRANSCODER: Checking [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] for corruption, please stand by ...
2019-12-23 21:09:34 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/tv/Vikings/Vikings.S06E0$
2019-12-23 21:09:35 INFO    ::TRANSCODER: SUCCESS: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] has no corruption.
2019-12-23 21:09:35 POSTPROCESS::SICKBEARD: SUCCESS: The download succeeded, sending a post-process request
2019-12-23 21:09:35 DEBUG   ::SICKBEARD: Opening URL: http://localhost:8083/api/be87600ad695b39a8071fa6a4851f8ad/?cmd=postprocess with params: {'failed': 0, 'process_method': 'move', 'force_next': 1, '$
2019-12-23 21:09:48 DEBUG   ::PLEX: Attempting to update Plex Library for category tv.
2019-12-23 21:09:49 DEBUG   ::PLEX: Plex Library has been refreshed.
2019-12-23 21:09:49 INFO    ::CLEANDIR: Directory /volume1/downloads/tv/Vikings has been processed and removed ...
2019-12-23 21:09:49 INFO    ::MAIN: The /volume1/@appstore/nzbToMedia/TorrentToMedia.py script completed successfully.
clinton-hall commented 4 years ago

you are now logged in is the return from synology that is capture in terminal with a manual run, but is not logged.

The main issues here are:

  1. The returned api call gives us status and data, then gives the data breakdown as per synology's documentation. I have now fixed this in the code.
  2. The download ID we are using is wrong! With a manual run, we don't have a download id, and we get a successful return but when called from DS, we get a 101 error (invalid parameter).

So now we need to find a way to get the correct download id!!!

so, what I am now doing is listing ALL downloads, and trying to match the download where the title matches the download name. This should then return the download id and the download destination...

try updating and run again (from DS)... Unless the title and torrent names are different, surely this has to be close now!

MrCee commented 4 years ago

This is almost there! So what's happened this time is that Download Station has returned EVERYTHING in the log, including old downloads I still had sitting in eMule. What this has shown me is the correct ID for Vikings.

So with this environment being set:

2019-12-24 04:44:15 INFO    ::ENVIRONMENT: TR_TORRENT_DIR: /var/services/download/1049
2019-12-24 04:44:15 INFO    ::ENVIRONMENT: TR_TIME_LOCALTIME: Tue Dec 24 04:43:51 2019
2019-12-24 04:44:15 INFO    ::ENVIRONMENT: TR_TORRENT_ID: 1049
2019-12-24 04:44:15 INFO    ::ENVIRONMENT: TR_TORRENT_HASH: 8b8670b11c7950d0489244fee214f3d0bb124a99
2019-12-24 04:44:15 INFO    ::ENVIRONMENT: TR_TORRENT_NAME: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-24 04:44:15 INFO    ::ENVIRONMENT: TR_APP_VERSION: 2.93

We can now see the ID for the first time...... 'id': 'dbid_1049'

2019-12-24 04:44:29 DEBUG   ::MAIN: result from syno {'success': True, 'data': {'offset': 0, 'total': 5, 'tasks': [{'size': 241728958, 'username': 'USERNAMEHIDDEN', 'additional': {'detail': {'seedelapsed': 0, 'uri': 'ed2k://|file|café%20solaire%209.rar|241728958|3AB1AE13ED8FB3E0050BCEB9749BB6FE|/', 'unzip_password': '', 'completed_time': 1557846581, 'lastSeenComplete': 1557846058, 'total_peers': 0, 'hash': '3AB1AE13ED8FB3E0050BCEB9749BB6FE', 'priority': 'auto', 'destination': 'downloads/complete', 'waiting_seconds': 0, 'connected_leechers': 0, 'create_time': 1557736405, 'connected_peers': 0, 'connected_seeders': 0, 'started_time': 0, 'total_pieces': 0}}, 'id': 'dbid_226', 'type': 'emule', 'status': 'finished', 'title': 'café solaire 9.rar'}, {'size': 290174732, 'username': 'USERNAMEHIDDEN', 'additional': {'detail': {'seedelapsed': 0, 'uri': 'ed2k://|file|Cafe%20Solaire%20Vol%2019%20-%202CD%20-2011..rar|290174732|035D425F0314CB451A18DD3ABA4533E3|/', 'unzip_password': '', 'completed_time': 1557759403, 'lastSeenComplete': 1557748081, 'total_peers': 0, 'hash': '035D425F0314CB451A18DD3ABA4533E3', 'priority': 'auto', 'destination': 'downloads/complete', 'waiting_seconds': 0, 'connected_leechers': 0, 'create_time': 1557744946, 'connected_peers': 0, 'connected_seeders': 0, 'started_time': 0, 'total_pieces': 0}}, 'id': 'dbid_229', 'type': 'emule', 'status': 'finished', 'title': 'Cafe Solaire Vol 19 - 2CD -2011..rar'}, {'size': 143368879, 'username': 'USERNAMEHIDDEN', 'additional': {'detail': {'seedelapsed': 0, 'uri': 'ed2k://|file|201_va_-_cafe_solaire_vol_19-drum.mp3|143368879|357DE3BA9027C658A3BC91C1C6336592|/', 'unzip_password': '', 'completed_time': 1558108990, 'lastSeenComplete': 1558103644, 'total_peers': 0, 'hash': '357DE3BA9027C658A3BC91C1C6336592', 'priority': 'auto', 'destination': 'downloads/complete', 'waiting_seconds': 0, 'connected_leechers': 0, 'create_time': 1557745032, 'connected_peers': 0, 'connected_seeders': 0, 'started_time': 0, 'total_pieces': 0}}, 'id': 'dbid_230', 'type': 'emule', 'status': 'finished', 'title': '201_va_-_cafe_solaire_vol_19-drum.mp3'}, {'size': 1494643934, 'username': 'USERNAMEHIDDEN', 'additional': {'detail': {'seedelapsed': 0, 'uri': 'magnet:?xt=urn:btih:2E7930CB66165DB01AF9B0FB204101C8CA9BE001&dn=His.Dark.Materials.S01E07.1080p.HDTV.H264-BRISK%5BTGx%5D+%E2%AD%90&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.tiny-vps.com%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.si%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce&tr=udp%3A%2F%2Ftracker.pirateparty.gr%3A6969%2Fannounce&tr=udp%3A%2F%2Fipv4.tracker.harry.lu%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.cyberia.is%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.to%3A2710%2Fannounce&tr=udp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fcoppersurfer.tk%3A6969%2Fannounce', 'completed_time': 0, 'unzip_password': '', 'total_peers': 0, 'started_time': 1576812035, 'waiting_seconds': 0, 'connected_leechers': 0, 'create_time': 1576812001, 'connected_peers': 5, 'connected_seeders': 0, 'destination': 'downloads/complete', 'total_pieces': 1426}}, 'id': 'dbid_1027', 'type': 'bt', 'status': 'paused', 'title': 'His.Dark.Materials.S01E07.1080p.HDTV.H264-BRISK[TGx]'}, {'size': 348244690, 'username': 'USERNAMEHIDDEN', 'additional': {'detail': {'seedelapsed': 0, 'uri': 'magnet:?xt=urn:btih:8B8670B11C7950D0489244FEE214F3D0BB124A99&dn=Vikings+S06E01+HDTV+x264-SVA+%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftorrent.gresille.org%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fcoppersurfer.tk%3A6969%2Fannounce', 'completed_time': 1577126634, 'unzip_password': '', 'total_peers': 0, 'started_time': 1577126379, 'waiting_seconds': 0, 'connected_leechers': 0, 'create_time': 1577126370, 'connected_peers': 0, 'connected_seeders': 0, 'destination': 'downloads/tv', 'total_pieces': 2657}}, 'id': 'dbid_1049', 'type': 'bt', 'status': 'finished', 'title': 'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv'}]}}
2019-12-24 04:44:29 DEBUG   ::MAIN: Adding TORRENT download info for directory downloads/tv to database
2019-12-24 04:44:29 DB      ::MAIN: nzbtomedia.db: UPDATE downloads SET input_name = ?, client_agent = ?, last_update = ?, input_id = ?, input_hash = ?, status = ? WHERE input_directory = ? with args ["b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv'", 'synods', 737417, 'dbid_1049', '8b8670b11c7950d0489244fee214f3d0bb124a99', 0, "b'downloads/tv'"]
2019-12-24 04:44:29 DB      ::MAIN: nzbtomedia.db: INSERT OR IGNORE INTO downloads (input_name, client_agent, last_update, input_id, input_hash, status) VALUES (?, ?, ?, ?, ?, ?) with args ["b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv'", 'synods', 737417, 'dbid_1049', '8b8670b11c7950d0489244fee214f3d0bb124a99', 0]
2019-12-24 04:44:29 DEBUG   ::MAIN: Received Directory: downloads/tv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category:
MrCee commented 4 years ago

@clinton-hall Here's another test, a complete log showing that TR_TORRENT_ID: 1050 = 'id': 'dbid_1050'

2019-12-24 05:12:48 INFO    ::MAIN: Loading config from [/volume1/@appstore/nzbToMedia/autoProcessMedia.cfg]
2019-12-24 05:12:48 INFO    ::ENVIRONMENT: TR_APP_VERSION: 2.93
2019-12-24 05:12:48 INFO    ::ENVIRONMENT: TR_TORRENT_DIR: /var/services/download/1050
2019-12-24 05:12:48 INFO    ::ENVIRONMENT: TR_TORRENT_HASH: 8b8670b11c7950d0489244fee214f3d0bb124a99
2019-12-24 05:12:48 INFO    ::ENVIRONMENT: TR_TORRENT_NAME: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-24 05:12:48 INFO    ::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
2019-12-24 05:12:48 INFO    ::ENVIRONMENT: TR_TIME_LOCALTIME: Tue Dec 24 05:12:21 2019
2019-12-24 05:12:48 INFO    ::ENVIRONMENT: TR_TORRENT_ID: 1050
2019-12-24 05:12:48 INFO    ::MAIN: Python v3.5 will reach end of life in 264 days.
2019-12-24 05:12:48 WARNING ::MAIN: Please upgrade to a more recent Python version.
2019-12-24 05:12:48 INFO    ::MAIN: Checking database structure...
2019-12-24 05:12:48 DEBUG   ::MAIN: Checking Initial Schema database upgrade
2019-12-24 05:12:48 DB      ::MAIN: nzbtomedia.db: SELECT 1 FROM sqlite_master WHERE name = ?; with args ('db_version',)
2019-12-24 05:12:48 DB      ::MAIN: nzbtomedia.db: SELECT db_version FROM db_version
2019-12-24 05:12:48 DEBUG   ::MAIN: InitialSchema upgrade not required
2019-12-24 05:12:48 DEBUG   ::MAIN: Checking if we can use git commands: "/usr/local/bin/git" version
2019-12-24 05:12:48 DEBUG   ::MAIN: Executing "/usr/local/bin/git" version with your shell in /volume1/@appstore/nzbToMedia
2019-12-24 05:12:48 DEBUG   ::MAIN: git output: git version 2.15.1
2019-12-24 05:12:48 DEBUG   ::MAIN: "/usr/local/bin/git" version : returned successful
2019-12-24 05:12:48 DEBUG   ::MAIN: Using: "/usr/local/bin/git"
2019-12-24 05:12:48 DEBUG   ::MAIN: Executing "/usr/local/bin/git" symbolic-ref -q HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-24 05:12:48 DEBUG   ::MAIN: git output: refs/heads/SynoDS-patch-1
2019-12-24 05:12:48 DEBUG   ::MAIN: "/usr/local/bin/git" symbolic-ref -q HEAD : returned successful
2019-12-24 05:12:48 INFO    ::MAIN: Checking if git needs an update
2019-12-24 05:12:48 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-24 05:12:48 DEBUG   ::MAIN: git output: 2dfd763ce2bb6bcf89f6ca671cffc5d2f51c2e5d
2019-12-24 05:12:48 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse HEAD : returned successful
2019-12-24 05:12:48 DEBUG   ::MAIN: Executing "/usr/local/bin/git" fetch origin with your shell in /volume1/@appstore/nzbToMedia
2019-12-24 05:12:53 DEBUG   ::MAIN: git output: 
2019-12-24 05:12:53 DEBUG   ::MAIN: "/usr/local/bin/git" fetch origin : returned successful
2019-12-24 05:12:53 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' with your shell in /volume1/@appstore/nzbToMedia
2019-12-24 05:12:53 DEBUG   ::MAIN: git output: 2a5afd2d7d4a80a264dad5d9d8c59d52e36eeb0f
2019-12-24 05:12:53 DEBUG   ::MAIN: "/usr/local/bin/git" rev-parse --verify --quiet '@{upstream}' : returned successful
2019-12-24 05:12:53 DEBUG   ::MAIN: Executing "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
2019-12-24 05:12:53 DEBUG   ::MAIN: git output: >2dfd763ce2bb6bcf89f6ca671cffc5d2f51c2e5d
>f76ed0a0f3c9ede3a89902131be6909faf7c0fe2
>3085056277cae99a10fe883c8b6b5fdf3d34fff5
>e4cc7c91218175adbab34abd103f42587ca07035
>b2a2364cdee6372443f3d845ff0567608986f91a
>fe6391a95ac6282e9bf8d80b1a7a4d8ebd02699d
>3a4efdb53c4b106c50d4458f0c8a5a0af60970f0
>4e41595038315e654184f321b0a1f65118f5db4a
>8e22f228fbc4f4d466fcf1d958541640d6d71f1b
>e386393bf2f8e5e9a92c2c2226b401ec02b82ff7
2019-12-24 05:12:53 DEBUG   ::MAIN: "/usr/local/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2019-12-24 05:12:53 DEBUG   ::MAIN: cur_commit = 2dfd763ce2bb6bcf89f6ca671cffc5d2f51c2e5d % (newest_commit)= 2a5afd2d7d4a80a264dad5d9d8c59d52e36eeb0f, num_commits_behind = 0, num_commits_ahead = 10
2019-12-24 05:12:53 INFO    ::MAIN: No update needed
2019-12-24 05:12:53 INFO    ::MAIN: nzbToMedia Version:2dfd763ce2bb6bcf89f6ca671cffc5d2f51c2e5d Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-24 05:12:55 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2019-12-24 05:13:00 INFO    ::MAIN: #########################################################
2019-12-24 05:13:00 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-24 05:13:00 INFO    ::MAIN: #########################################################
2019-12-24 05:13:00 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2019-12-24 05:13:00 DEBUG   ::MAIN: result from syno {'data': {'total': 1, 'tasks': [{'username': 'USERNAMEHIDDEN', 'type': 'bt', 'status': 'finished', 'size': 348244690, 'title': 'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv', 'additional': {'detail': {'connected_peers': 0, 'waiting_seconds': 0, 'connected_leechers': 0, 'seedelapsed': 0, 'create_time': 1577128051, 'connected_seeders': 0, 'destination': 'downloads/tv', 'uri': 'magnet:?xt=urn:btih:8B8670B11C7950D0489244FEE214F3D0BB124A99&dn=Vikings+S06E01+HDTV+x264-SVA+%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftorrent.gresille.org%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fcoppersurfer.tk%3A6969%2Fannounce', 'total_pieces': 2657, 'unzip_password': '', 'completed_time': 1577128346, 'started_time': 1577128073, 'total_peers': 0}}, 'id': 'dbid_1050'}], 'offset': 0}, 'success': True}
2019-12-24 05:13:00 DEBUG   ::MAIN: Adding TORRENT download info for directory downloads/tv to database
2019-12-24 05:13:00 DB      ::MAIN: nzbtomedia.db: UPDATE downloads SET input_name = ?, input_hash = ?, status = ?, last_update = ?, client_agent = ?, input_id = ? WHERE input_directory = ? with args ["b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv'", '8b8670b11c7950d0489244fee214f3d0bb124a99', 0, 737417, 'synods', 'dbid_1050', "b'downloads/tv'"]
2019-12-24 05:13:00 DB      ::MAIN: nzbtomedia.db: INSERT OR IGNORE INTO downloads (input_name, input_hash, status, last_update, client_agent, input_id) VALUES (?, ?, ?, ?, ?, ?) with args ["b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv'", '8b8670b11c7950d0489244fee214f3d0bb124a99', 0, 737417, 'synods', 'dbid_1050']
2019-12-24 05:13:00 DEBUG   ::MAIN: Received Directory: downloads/tv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category: 
2019-12-24 05:13:00 DEBUG   ::MAIN: SEARCH: Found Category: tv in directory structure
2019-12-24 05:13:00 INFO    ::MAIN: SEARCH: Could not find a unique directory for this download. Assume a common directory.
2019-12-24 05:13:00 INFO    ::MAIN: SEARCH: We will try and determine which files to process, individually
2019-12-24 05:13:00 DEBUG   ::MAIN: Determined Directory: downloads/tv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category: tv
2019-12-24 05:13:01 INFO    ::MAIN: Auto-detected SECTION:SickBeard
2019-12-24 05:13:01 DEBUG   ::MAIN: Stopping torrent Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in synods while processing
2019-12-24 05:13:06 INFO    ::MAIN: Output directory set to: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv]
2019-12-24 05:13:06 DEBUG   ::MAIN: Scanning files in directory: downloads/tv
2019-12-24 05:13:06 DEBUG   ::MAIN: Found 0 files in downloads/tv
2019-12-24 05:13:06 DEBUG   ::MAIN: Checking for archives to extract in directory: downloads/tv
2019-12-24 05:13:06 INFO    ::MAIN: FLATTEN: Flattening directory: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv]
2019-12-24 05:13:06 WARNING ::MAIN: Found no media files in /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv]
2019-12-24 05:13:06 INFO    ::MAIN: Calling SickBeard:tv to post-process:Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-24 05:13:06 INFO    ::MAIN: Changing file mode of /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv] to 0o777
clinton-hall commented 4 years ago

interesting.... so the script does indeed find the correct torrent details, and stop the torrent.

I could just make the conversion from TR_TORRENTID to id by appending `dbid` first... but the way it is done now should be more robust...

the issue is we get the directory downloads/tv but this is a relative directory, presumably in the ~share

do you know if there is a way I can confirm where this is relative to? i.e. is there a default symlink /share/ or /usr/share/ or an environment variable (none that I have seen in logs)?

I could just hard-code /volume1 to make it /volume1/downloads/tv but I want to make it work with other configs... even if it were set to /volume2 etc...

clinton-hall commented 4 years ago

ok, I have added a test to see if the path exists in case DS can be configured with absolute paths for categories.... which if possible would be my recommendation. e.g. instead of Sonarr category having destination downloads/tv this would be set as /volume1/downloads/tv in DS....

If the path doesn't exist, this will then add /volume1/ in front (assuming that that the resulting path does exist...)

This change I think should get things working for you. If there is a better way to handle the relative paths, please let me know.

MrCee commented 4 years ago

@clinton-hall

I was thinking that appending dbid_ to TR_TORRENT_ID would be the best way to open up other possibilities with the API, but if I'm following what you are achieving via file match to ID? I'm not sure if I'm correct here. For the first time in many years I have seen the script interact via API and the download file was also removed from the GUI and fully post-processed.
Still trying to up-skill with Python :) None the less, I think you have done it!! Awesome :)

Re: relative directories... I had a search around Synology NAS trying to find a way to determine the path of the relative directories, and tried to look at how SickChill does this, but always keep coming back to this.... Anyone else using TorrentToMedia.py would set this in autoProcessMedia.cfg in case of a manual run.... (usually?).....

    ###### outputDirectory - Default output directory (categories will be appended as sub directory to outputDirectory)
    outputDirectory = /volume1/downloads/

Here is the log from an updated TorrentToMedia.py triggered by Synology Download Station completing the download:

2019-12-26 19:06:38 INFO    ::MAIN: nzbToMedia Version:0d2fbfd6592b7a473cf935e21fe9367acce5419a Branch:SynoDS-patch-1 (Linux 3.2.40)
2019-12-26 19:06:39 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2019-12-26 19:06:42 INFO    ::MAIN: #########################################################
2019-12-26 19:06:42 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2019-12-26 19:06:42 INFO    ::MAIN: #########################################################
2019-12-26 19:06:42 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2019-12-26 19:06:43 DEBUG   ::MAIN: result from syno {'success': True, 'data': {'offset': 0, 'tasks': [{'type': 'bt', 'additional': {'detail': {'connected_peers': 0, 'total_pieces': 2657, 'connected_seeders': 0, 'completed_time': 1577351176, 'seedelapsed': 0, 'create_time': 1577350888, 'started_time': 1577350905, 'total_peers': 0, 'destination': 'downloads/tv', 'waiting_seconds': 0, 'unzip_password': '', 'connected_leechers': 0, 'uri': 'magnet:?xt=urn:btih:8B8670B11C7950D0489244FEE214F3D0BB124A99&dn=Vikings+S06E01+HDTV+x264-SVA+%5Beztv%5D&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Ftorrent.gresille.org%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337&tr=udp%3A%2F%2Ftracker.internetwarriors.net%3A1337&tr=udp%3A%2F%2Ftracker.zer0day.to%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fcoppersurfer.tk%3A6969%2Fannounce'}}, 'title': 'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv', 'id': 'dbid_1077', 'username': 'USERNAMEHIDDEN', 'size': 348244690, 'status': 'finished'}], 'total': 1}}
2019-12-26 19:06:43 DEBUG   ::MAIN: Adding TORRENT download info for directory /volume1/downloads/tv to database
2019-12-26 19:06:43 DB      ::MAIN: nzbtomedia.db: UPDATE downloads SET input_hash = ?, client_agent = ?, status = ?, input_id = ?, last_update = ?, input_name = ? WHERE input_directory = ? with args ['8b8670b11c7950d0489244fee214f3d0bb124a99', 'synods', 0, 'dbid_1077', 737419, "b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv'", "b'/volume1/downloads/tv'"]
2019-12-26 19:06:43 DB      ::MAIN: nzbtomedia.db: INSERT OR IGNORE INTO downloads (input_hash, client_agent, status, input_id, last_update, input_name) VALUES (?, ?, ?, ?, ?, ?) with args ['8b8670b11c7950d0489244fee214f3d0bb124a99', 'synods', 0, 'dbid_1077', 737419, "b'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv'"]
2019-12-26 19:06:43 DEBUG   ::MAIN: Received Directory: /volume1/downloads/tv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category:
2019-12-26 19:06:43 DEBUG   ::MAIN: SEARCH: Found Category: tv in directory structure
2019-12-26 19:06:44 INFO    ::MAIN: SEARCH: Found torrent file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in input directory directory /volume1/downloads/tv
2019-12-26 19:06:44 INFO    ::MAIN: SEARCH: Setting input_directory to /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:44 DEBUG   ::MAIN: Determined Directory: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category: tv
2019-12-26 19:06:44 INFO    ::MAIN: Auto-detected SECTION:SickBeard
2019-12-26 19:06:44 DEBUG   ::MAIN: Stopping torrent Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in synods while processing
2019-12-26 19:06:49 INFO    ::MAIN: Output directory set to: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 DEBUG   ::MAIN: Scanning files in directory: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 DEBUG   ::MAIN: Found 1 files in /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 INFO    ::COPYLINK: MEDIAFILE: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv]
2019-12-26 19:06:49 INFO    ::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
2019-12-26 19:06:49 INFO    ::COPYLINK: TARGET FOLDER: [/volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv]
2019-12-26 19:06:49 INFO    ::COPYLINK: SOURCE AND TARGET folders are the same, skipping ...
2019-12-26 19:06:49 DEBUG   ::MAIN: Checking for archives to extract in directory: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 INFO    ::MAIN: FLATTEN: Flattening directory: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 ERROR   ::FLATTEN: Could not flatten /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 INFO    ::MAIN: Found 1 media files in /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 INFO    ::MAIN: Calling SickBeard:tv to post-process:Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:49 INFO    ::MAIN: Changing file mode of /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv to 0o777
2019-12-26 19:06:49 DEBUG   ::SERVER: Attempting to connect to server at http://localhost:8083
2019-12-26 19:06:51 DEBUG   ::SERVER: Server responded at http://localhost:8083
2019-12-26 19:06:51 INFO    ::MAIN: SickBeard:tv fork set to SickChill
2019-12-26 19:06:51 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
2019-12-26 19:06:52 INFO    ::TRANSCODER: Checking [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] for corruption, please stand by ...
2019-12-26 19:06:52 DEBUG   ::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2019-12-26 19:06:52 INFO    ::TRANSCODER: SUCCESS: [Vikings.S06E01.HDTV.x264-SVA[eztv].mkv] has no corruption.
2019-12-26 19:06:52 POSTPROCESS::SICKBEARD: SUCCESS: The download succeeded, sending a post-process request
2019-12-26 19:06:52 DEBUG   ::SICKBEARD: Opening URL: http://localhost:8083/api/be87600ad695b39a8071fa6a4851f8ad/?cmd=postprocess with params: {'force_next': 1, 'proc_dir': '/volume1/downloads/tv', 'nzbName': 'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv', 'delete_on': 1, 'process_method': 'move', 'quiet': 1, 'failed': 0}
2019-12-26 19:07:04 DEBUG   ::PLEX: Attempting to update Plex Library for category tv.
2019-12-26 19:07:04 DEBUG   ::PLEX: Plex Library has been refreshed.
2019-12-26 19:07:04 DB      ::DB: Updating DB download status of Vikings.S06E01.HDTV.x264-SVA[eztv].mkv to 1
2019-12-26 19:07:04 DB      ::MAIN: nzbtomedia.db: UPDATE downloads SET status=?, last_update=? WHERE input_name=? with args [1, 737419, 'Vikings.S06E01.HDTV.x264-SVA[eztv].mkv']
2019-12-26 19:07:05 DEBUG   ::MAIN: Deleting torrent Vikings.S06E01.HDTV.x264-SVA[eztv].mkv from synods
2019-12-26 19:07:13 INFO    ::CLEANDIR: Directory /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv has been processed and removed ...
2019-12-26 19:07:13 INFO    ::MAIN: The /volume1/@appstore/nzbToMedia/TorrentToMedia.py script completed successfully.
clinton-hall commented 4 years ago

great news, glad to hear it worked.

this should work for most syno configs unless people have really customized things, however I'm still keen to tidy up a few things here:

1. Use dbid_ to TR_TORRENT_ID as primary search (returns less logging from syno as well)
2. Use complete download list as secondary match (to download name) In case dbid_TR_TORRENT_ID doesn't match
3. Either find a way to determine relative "download" path as an absolute path, or
3. Create a config option to pass in the "absolute" path to be appended
4. Remove the syno output logging (although, this is debug, so maybe it's not a problem...)
5. Bypass syno api (and error logging) when no download id or download name (manual processing)
MrCee commented 4 years ago

@clinton-hall Definitely let me know where I can test further. Great work.

I thought I could quickly test a manual run with many other items in the queue that are not complete, and there are no issues with that either. Vikings was post-processed manually.

20:20:21] [INFO]::MAIN: nzbToMedia Version:0d2fbfd6592b7a473cf935e21fe9367acce5419a Branch:SynoDS-patch-1 (Linux 3.2.40)
[20:20:23] [DEBUG]::MAIN: Connecting to synology: http://localhost:5000
You are now logged in!
[20:20:26] [INFO]::MAIN: #########################################################
[20:20:26] [INFO]::MAIN: ## ..::[TorrentToMedia.py]::.. ##
[20:20:26] [INFO]::MAIN: #########################################################
[20:20:26] [DEBUG]::MAIN: Options passed into TorrentToMedia: ['/nzbToMedia/TorrentToMedia.py']
[20:20:28] [DEBUG]::MAIN: result from syno {'success': True, 'data': {'tasks': [{'additional': {'detail': {'connected_peers': 46, 'destination': 'downloads/tv', 'create_time': 1577353394, 'total_peers': 0, 'total_pieces': 284, 'connected_seeders': 17, 'completed_time': 0, 'started_time': 1577353407, 'uri': 'magnet:?xt=urn:btih:93ffc7adf5c22651f9fb9015d2e849a226665729&dn=You.S02E01.INTERNAL.WEB.x264-STRiFE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce', 'unzip_password': '', 'seedelapsed': 0, 'waiting_seconds': 0, 'connected_leechers': 4}}, 'type': 'bt', 'username': 'USERNAMEHIDDEN', 'size': 297115819, 'title': 'You.S02E01.INTERNAL.WEB.x264-STRiFE[rarbg]', 'id': 'dbid_1079', 'status': 'paused'}, {'additional': {'detail': {'connected_peers': 28, 'destination': 'downloads/tv', 'create_time': 1577353400, 'total_peers': 0, 'total_pieces': 278, 'connected_seeders': 11, 'completed_time': 0, 'started_time': 1577353411, 'uri': 'magnet:?xt=urn:btih:455db6dabab5e86abdc5ccb1ade5e4d0acf670d1&dn=You.S02E02.INTERNAL.WEB.x264-STRiFE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce', 'unzip_password': '', 'seedelapsed': 0, 'waiting_seconds': 0, 'connected_leechers': 6}}, 'type': 'bt', 'username': 'USERNAMEHIDDEN', 'size': 291266361, 'title': 'You.S02E02.INTERNAL.WEB.x264-STRiFE[rarbg]', 'id': 'dbid_1080', 'status': 'paused'}, {'additional': {'detail': {'connected_peers': 34, 'destination': 'downloads/tv', 'create_time': 1577353406, 'total_peers': 0, 'total_pieces': 278, 'connected_seeders': 13, 'completed_time': 0, 'started_time': 1577353465, 'uri': 'magnet:?xt=urn:btih:34058e188a49419a2b442d1b845fd0d20f476210&dn=You.S02E03.INTERNAL.WEB.x264-STRiFE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce', 'unzip_password': '', 'seedelapsed': 0, 'waiting_seconds': 0, 'connected_leechers': 8}}, 'type': 'bt', 'username': 'USERNAMEHIDDEN', 'size': 290618192, 'title': 'You.S02E03.INTERNAL.WEB.x264-STRiFE[rarbg]', 'id': 'dbid_1081', 'status': 'paused'}, {'additional': {'detail': {'connected_peers': 29, 'destination': 'downloads/tv', 'create_time': 1577353411, 'total_peers': 0, 'total_pieces': 207, 'connected_seeders': 12, 'completed_time': 0, 'started_time': 1577353480, 'uri': 'magnet:?xt=urn:btih:97d37536dfa1d6aeb879a8ef6fa4e2495a2e924f&dn=You.S02E04.INTERNAL.WEB.x264-STRiFE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce', 'unzip_password': '', 'seedelapsed': 0, 'waiting_seconds': 0, 'connected_leechers': 4}}, 'type': 'bt', 'username': 'USERNAMEHIDDEN', 'size': 216746795, 'title': 'You.S02E04.INTERNAL.WEB.x264-STRiFE[rarbg]', 'id': 'dbid_1082', 'status': 'paused'}, {'additional': {'detail': {'connected_peers': 26, 'destination': 'downloads/tv', 'create_time': 1577353415, 'total_peers': 0, 'total_pieces': 297, 'connected_seeders': 13, 'completed_time': 0, 'started_time': 1577353469, 'uri': 'magnet:?xt=urn:btih:6b6baa732e0567032845013d8a3c3cb3e93a95c1&dn=You.S02E05.INTERNAL.WEB.x264-STRiFE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce', 'unzip_password': '', 'seedelapsed': 0, 'waiting_seconds': 0, 'connected_leechers': 6}}, 'type': 'bt', 'username': 'USERNAMEHIDDEN', 'size': 310930134, 'title': 'You.S02E05.INTERNAL.WEB.x264-STRiFE[rarbg]', 'id': 'dbid_1083', 'status': 'paused'}, {'additional': {'detail': {'connected_peers': 42, 'destination': 'downloads/tv', 'create_time': 1577353430, 'total_peers': 0, 'total_pieces': 692, 'connected_seeders': 19, 'completed_time': 0, 'started_time': 1577353473, 'uri': 'magnet:?xt=urn:btih:12f89245abce29d05b8bc9ac0df61f088308c627&dn=YOU.S02E08.iNTERNAL.WEB.X264-STARZ%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce', 'unzip_password': '', 'seedelapsed': 0, 'waiting_seconds': 0, 'connected_leechers': 9}}, 'type': 'bt', 'username': 'USERNAMEHIDDEN', 'size': 725041451, 'title': 'YOU.S02E08.iNTERNAL.WEB.X264-STARZ[rarbg]', 'id': 'dbid_1086', 'status': 'paused'}, {'additional': {'detail': {'connected_peers': 25, 'destination': 'downloads/tv', 'create_time': 1577353443, 'total_peers': 0, 'total_pieces': 279, 'connected_seeders': 18, 'completed_time': 0, 'started_time': 1577353550, 'uri': 'magnet:?xt=urn:btih:c1c5611e1d64b472fff4e360befb86c71c552f76&dn=You.S02E10.INTERNAL.WEB.x264-STRiFE%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2710&tr=udp%3A%2F%2F9.rarbg.to%3A2710&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce', 'unzip_password': '', 'seedelapsed': 0, 'waiting_seconds': 0, 'connected_leechers': 3}}, 'type': 'bt', 'username': 'USERNAMEHIDDEN', 'size': 291850885, 'title': 'You.S02E10.INTERNAL.WEB.x264-STRiFE[rarbg]', 'id': 'dbid_1088', 'status': 'paused'}], 'offset': 0, 'total': 7}}
[20:20:28] [ERROR]::MAIN: unable to find download details in Synology DS
[20:20:28] [WARNING]::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
[20:20:28] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[20:20:28] [INFO]::MAIN: Searching /volume1/downloads/movie for mediafiles to post-process ...
[20:20:28] [DEBUG]::MAIN: No directories identified in Radarr:movie for post-processing
[20:20:28] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[20:20:28] [DEBUG]::MAIN: Found file Vikings.S06E01.New.Beginnings.HDTV.x264.mkv in root directory /volume1/downloads/tv.
[20:20:29] [INFO]::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.New.Beginnings.HDTV.x264.mkv']
[20:20:29] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
[20:20:29] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
[20:20:29] [INFO]::COPYLINK: Hard linking SOURCE MEDIAFILE -> TARGET FOLDER
[20:20:29] [INFO]::MAIN: Searching /volume1/downloads/tv for mediafiles to post-process ...
[20:20:29] [DEBUG]::MAIN: Found file Vikings.S06E01.New.Beginnings.HDTV.x264.mkv in root directory /volume1/downloads/tv.
[20:20:30] [INFO]::COPYLINK: MEDIAFILE: [b'Vikings.S06E01.New.Beginnings.HDTV.x264.mkv']
[20:20:30] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv]
[20:20:30] [INFO]::COPYLINK: TARGET FOLDER: [b'/volume1/downloads/tv/Vikings']
[20:20:30] [INFO]::COPYLINK: MEDIAFILE already exists in the TARGET folder, skipping ...
[20:20:30] [INFO]::MAIN: Starting manual run for SickBeard:tv - Folder:/volume1/downloads/tv/Vikings
[20:20:30] [INFO]::MAIN: Checking database for download info for Vikings ...
[20:20:30] [DB]::DB: Getting download info for Vikings from the DB
[20:20:30] [DB]::MAIN: nzbtomedia.db: SELECT * FROM downloads WHERE input_name=? AND status=? with args ['Vikings', 0]
[20:20:30] [INFO]::MAIN: Unable to locate download info for Vikings, continuing to try and process this release ...
[20:20:30] [DEBUG]::MAIN: Received Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
[20:20:30] [DEBUG]::MAIN: SEARCH: Found the Category: tv in directory structure
[20:20:30] [INFO]::MAIN: SEARCH: Found a unique directory Vikings in the category directory
[20:20:30] [DEBUG]::MAIN: Determined Directory: /volume1/downloads/tv/Vikings | Name: Vikings | Category: tv
[20:20:30] [INFO]::MAIN: Auto-detected SECTION:SickBeard
[20:20:30] [INFO]::MAIN: Output directory set to: /volume1/downloads/tv/Vikings
[20:20:30] [DEBUG]::MAIN: Scanning files in directory: /volume1/downloads/tv/Vikings
[20:20:30] [DEBUG]::MAIN: Found 1 files in /volume1/downloads/tv/Vikings
[20:20:30] [INFO]::COPYLINK: MEDIAFILE: [Vikings.S06E01.New.Beginnings.HDTV.x264.mkv]
[20:20:30] [INFO]::COPYLINK: SOURCE FOLDER: [/volume1/downloads/tv/Vikings]
[20:20:30] [INFO]::COPYLINK: TARGET FOLDER: [/volume1/downloads/tv/Vikings]
[20:20:30] [INFO]::COPYLINK: SOURCE AND TARGET files are the same, skipping ...
[20:20:30] [DEBUG]::MAIN: Checking for archives to extract in directory: /volume1/downloads/tv/Vikings
[20:20:30] [INFO]::MAIN: FLATTEN: Flattening directory: /volume1/downloads/tv/Vikings
[20:20:30] [DEBUG]::MAIN: Checking for empty folders in:/volume1/downloads/tv/Vikings
[20:20:30] [INFO]::MAIN: Found 1 media files in /volume1/downloads/tv/Vikings
[20:20:30] [INFO]::MAIN: Calling SickBeard:tv to post-process:Vikings
[20:20:30] [INFO]::MAIN: Changing file mode of /volume1/downloads/tv/Vikings to 0o777
[20:20:30] [DEBUG]::SERVER: Attempting to connect to server at http://localhost:8083
[20:20:32] [DEBUG]::SERVER: Server responded at http://localhost:8083
[20:20:32] [INFO]::MAIN: SickBeard:tv fork set to SickChill
[20:20:32] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/@appstore/nzbToMedia/tests/test.mp4
[20:20:34] [INFO]::TRANSCODER: Checking [Vikings.S06E01.New.Beginnings.HDTV.x264.mkv] for corruption, please stand by ...
[20:20:34] [DEBUG]::MAIN: calling command: /volume1/@appstore/ffmpeg/bin/ffprobe -v quiet -print_format json -show_format -show_streams -show_error /volume1/downloads/tv/Vikings/Vikings.S06E01.New.Beginnings.HDTV.x264.mkv
[20:20:34] [INFO]::TRANSCODER: SUCCESS: [Vikings.S06E01.New.Beginnings.HDTV.x264.mkv] has no corruption.
[20:20:34] [POSTPROCESS]::SICKBEARD: SUCCESS: The download succeeded, sending a post-process request
[20:20:34] [DEBUG]::SICKBEARD: Opening URL: http://localhost:8083/api/be87600ad695b39a8071fa6a4851f8ad/?cmd=postprocess with params: {'quiet': 1, 'nzbName': 'Vikings', 'force_next': 1, 'process_method': 'move', 'failed': 0, 'proc_dir': '/volume1/downloads/tv/Vikings', 'delete_on': 1}
[20:20:46] [DEBUG]::PLEX: Attempting to update Plex Library for category tv.
[20:20:46] [DEBUG]::PLEX: Plex Library has been refreshed.
[20:20:46] [INFO]::CLEANDIR: Directory /volume1/downloads/tv/Vikings has been processed and removed ...
[20:20:46] [INFO]::MAIN: The /nzbToMedia/TorrentToMedia.py script completed successfully.
clinton-hall commented 4 years ago

re: outputDirectory = /volume1/downloads/

This is the directory that is set in nzbToMedia to "stage" the downloads to be processed by SickChill etc... this is not the directory that Syno DS downloads to (although in your case this is the same).

Usually the files are either sym-linked, hard-linked, copied, moved, (or in the case or zip/rar... extracted) FROM the synology DS (or downloader location) TO the outputDirectory...

because your Syno DS destination is the same as outputDirectory you get :COPYLINK: SOURCE AND TARGET folders are the same, skipping ... which is fine... since you don't want to keep seeding. If you did want to keep seeding we would need to use the staging directory to link to so that SickChill could move the linked file etc.

I do note the 1 error you got orriginally ERROR ::FLATTEN: Could not flatten /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv this again stems from the fact that this is the original syno DS destination and it either has permissions or a lock (for seeding) that prevent this from being moved/altered. Not a big deal, since again you delete the torrent afterwards via api. If using a different outputDirectory, that would usually be the directory that is flattened.

The main reason for flattening (from memory) is to bring all sub-foldered videos up to top level so sickbeard could see them all (processing an entire season directory etc). I am not even sure if this is still required for more modern variants.

The other error, in your last run, [ERROR]::MAIN: unable to find download details in Synology DS was just confirming that we couldn't find the match to the download name (none) since this was a manual run... I should add this to my list above... when we don't have any download name we should just by-pass this check and go straight to manual processing.

MrCee commented 4 years ago

Just going through some detail, there maybe something useful here...

In Synology Download Station GUI we can select a "Temporary Location" pick list e.g. "Volume 1", "Volume 2", "Volume3". Only the volume. As a result, a symlink is created /var/services/download will symlink to (in this case) /volume1/@download... So I guess that's how you always find your temp location volume.

user@synoNAS:/# realpath /var/services/download
/volume1/@download

There is also a "Default Destination Folder" which is a catch all for manually added files and in the GUI it could be any shared folder no matter which volume. In the GUI my folder is set to downloads/complete which is essentially /volume1/downloads/complete/ but this is only used with a manual addition of a file to Synology Download Station and nzbToMedia script's don't usually work with this folder (I haven't set it up / haven't tested / UNCAT)

If SickChill/Radarr/CouchPotato/others add a torrent to Download Station, the "Default Destination Folder" is overwritten by the location specified in the client. e.g. SickChill overwrites the default location and it is shown against the file in the Synology Download Station GUI as downloads/tv gleaned from SickChill config.ini path = downloads/tv. Still it doesn't show the volume but SickChill do mention "note: the destination has to be a shared folder for Synology DS" in SC GUI, I'm not sure how they work it out exactly although have tried to understand.

RE: [ERROR]::MAIN: unable to find download details in Synology DS in my last log... there was a whole lot of detail parsed to the script while I paused many downloads just to test the manual run as Vikings was complete, so, if not appending dbid_ to TR_TORRENT_ID yet, this may not be an issue or could be resolved shortly? There was many 'status': 'paused' in that log, so I'm not sure what happened there, but hope this helps.

clinton-hall commented 4 years ago

ok, if you could check again... this should make manual processing a lot cleaner.

I have also limited this to search by dbid_Toreent-id and I have alos checked for relative paths in volume1 to volume4 (from what I read, these must be shares which sit on a volume... and 4 should be enough for most users).

MrCee commented 4 years ago

Hi Clinton, Apologies for the delay, I'm able to continue testing this now. One thing I thought I would mention now is to include synoPort = 5000 in autpProcessMedia.cfg as per the API documentation. From recent testing I found that any other port previously mentioned elsewhere (9091 or 9093) doesn't work with API. I will update the wiki shortly.

So should I now be testing this on nightly? I'm currently stuck at this on nightly...

2020-01-21 07:04:50 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2020-01-21 07:04:54 INFO    ::MAIN: #########################################################
2020-01-21 07:04:54 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2020-01-21 07:04:54 INFO    ::MAIN: #########################################################
2020-01-21 07:04:54 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2020-01-21 07:04:55 DEBUG   ::MAIN: result from syno {'error': {'code': 101}, 'success': False}
2020-01-21 07:04:55 WARNING ::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
clinton-hall commented 4 years ago

Sorry that was a silly error on my part when I went back to using download ID.

Can you test again? This will hopefully do what you want.

MrCee commented 4 years ago

Unfortunately it's still the same...

2020-01-22 11:17:55 INFO    ::ENVIRONMENT: TR_TORRENT_ID: 1222
2020-01-22 11:17:55 INFO    ::ENVIRONMENT: TR_TIME_LOCALTIME: Wed Jan 22 11:17:38 2020
2020-01-22 11:17:55 INFO    ::ENVIRONMENT: TR_TORRENT_HASH: 8b8670b11c7950d0489244fee214f3d0bb124a99
2020-01-22 11:17:55 INFO    ::ENVIRONMENT: PATH: /sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
2020-01-22 11:17:55 INFO    ::ENVIRONMENT: TR_TORRENT_DIR: /volume1/downloads/tv
2020-01-22 11:17:55 INFO    ::ENVIRONMENT: TR_APP_VERSION: 2.93
2020-01-22 11:17:55 INFO    ::ENVIRONMENT: TR_TORRENT_NAME: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2020-01-22 11:18:01 INFO    ::MAIN: #########################################################
2020-01-22 11:18:01 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2020-01-22 11:18:01 INFO    ::MAIN: #########################################################
2020-01-22 11:18:01 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2020-01-22 11:18:01 WARNING ::MAIN: Invalid number of arguments received from client, Switching to manual run mode ...
clinton-hall commented 4 years ago

nope... that's different... we didn't get returned data from Syno this time...

MrCee commented 4 years ago

@clinton-hall Not sure what I did last, recently re-installed DSM. All of the above changes seem to be working automagically now and API with the DownloadStation client is spot on! Awesome work, thank you.

2020-01-22 16:40:14 DEBUG   ::MAIN: Executing "/volume1/@appstore/git/bin/git" rev-list --left-right '@{upstream}'...HEAD with your shell in /volume1/@appstore/nzbToMedia
2020-01-22 16:40:14 DEBUG   ::MAIN: git output:
2020-01-22 16:40:14 DEBUG   ::MAIN: "/volume1/@appstore/git/bin/git" rev-list --left-right '@{upstream}'...HEAD : returned successful
2020-01-22 16:40:14 DEBUG   ::MAIN: cur_commit = 11f1c2ce3ffb85c0173ce973de17406f3c932673 % (newest_commit)= 11f1c2ce3ffb85c0173ce973de17406f3c932673, num_commits_behind = 0, num_commits_ahead = 0
2020-01-22 16:40:14 INFO    ::MAIN: No update needed
2020-01-22 16:40:14 INFO    ::MAIN: nzbToMedia Version:11f1c2ce3ffb85c0173ce973de17406f3c932673 Branch:nightly (Linux 3.2.40)
2020-01-22 16:40:15 WARNING ::MAIN: Failed to locate par2. Repair and rename using par files will not be possible!
2020-01-22 16:40:15 DEBUG   ::MAIN: Connecting to synology: http://localhost:5000
2020-01-22 16:40:18 INFO    ::MAIN: #########################################################
2020-01-22 16:40:18 INFO    ::MAIN: ## ..::[TorrentToMedia.py]::.. ##
2020-01-22 16:40:18 INFO    ::MAIN: #########################################################
2020-01-22 16:40:18 DEBUG   ::MAIN: Options passed into TorrentToMedia: ['/volume1/@appstore/nzbToMedia/TorrentToMedia.py']
2020-01-22 16:40:19 DEBUG   ::MAIN: result from syno {'success': True, 'data': {'tasks': [{'additional': {'detail': {'connected_leechers': 0, 'create_time': 1579675084, 'destination': 'downloads/tv', 't>
2020-01-22 16:40:19 DEBUG   ::MAIN: Adding TORRENT download info for directory /volume1/downloads/tv to database
2020-01-22 16:40:19 DB      ::MAIN: nzbtomedia.db: UPDATE downloads SET input_id = ?, client_agent = ?, input_name = ?, input_hash = ?, status = ?, last_update = ? WHERE input_directory = ? with args ['>
2020-01-22 16:40:19 DB      ::MAIN: nzbtomedia.db: INSERT OR IGNORE INTO downloads (input_id, client_agent, input_name, input_hash, status, last_update) VALUES (?, ?, ?, ?, ?, ?) with args ['dbid_1229',>
2020-01-22 16:40:19 DEBUG   ::MAIN: Received Directory: /volume1/downloads/tv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category:
2020-01-22 16:40:19 DEBUG   ::MAIN: SEARCH: Found Category: tv in directory structure
2020-01-22 16:40:19 INFO    ::MAIN: SEARCH: Found torrent file Vikings.S06E01.HDTV.x264-SVA[eztv].mkv in input directory directory /volume1/downloads/tv
2020-01-22 16:40:19 INFO    ::MAIN: SEARCH: Setting input_directory to /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv
2020-01-22 16:40:19 DEBUG   ::MAIN: Determined Directory: /volume1/downloads/tv/Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Name: Vikings.S06E01.HDTV.x264-SVA[eztv].mkv | Category: tv
2020-01-22 16:40:19 INFO    ::MAIN: Auto-detected SECTION:SickBeard

Just for your notes, I'm still working on a solution regarding altered Apparmor profile loaded at start-up, as it seems that Synology use a pre-complied profile at start-up which doesn't include the additional permissions we require for /volume*/@appstore/nzbToMedia{,**} rwux,.

Wiki has been updated. Cheers!

clinton-hall commented 4 years ago

great news... I was just looking over the code and couldn't see what was going wrong... so good to see it is working and I'm not loosing the plot!