├── .gitignore ├── Filebot_Logs.MD ├── LICENSE ├── Notification_Processor.py └── README.MD /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | fb-telegram_Notes\.txt 3 | 4 | comments\.txt 5 | 6 | README\.html 7 | 8 | Torrents\.txt 9 | -------------------------------------------------------------------------------- /Filebot_Logs.MD: -------------------------------------------------------------------------------- 1 | # FILEBOT LOGS 2 | 3 | * **APPLICATION:** Filebot CLI (not a separate program.) 4 | * NOTES: Add filebot to Environment Path to make execution convenient. Add `filebot.launcher.exe` in the environment path in the previous step if you want to prevent the console from popping up. 5 | * **AUTHOR:** [Arion Miles](https://github.com/ArionMiles) 6 | 7 | ## qBittorrent 8 | 9 | **Date: 23 Feb, 2018:** 10 | 11 | There was a problem with getting powershell to execute the Notification_Processor after Filebot was done renaming and moving the files. I now execute the `Notification_Processor.py` from inside the `args.txt` instead of separately executing them with powershell because for some reason they do not execute one after the other. 12 | 13 | This is the new `args.txt` for **Telegram**: 14 | ``` 15 | echo {quote("${any{episode; n}{movie}}")} | Out-File -Encoding UTF8 E:\New\config\SeriesName.txt; echo {quote("${episode; s00e00 + ' - ' + t}")} | Out-File -Encoding UTF8 E:\New\config\EpisodeDet.txt -append; Notification_Processor.py 16 | ``` 17 | 18 | This is the new qBittorrent script: 19 | ``` 20 | powershell -Command "&{&'filebot.launcher' -script fn:amc --output '"E:\\"' --action 'move' --conflict 'skip' -non-strict --log-file 'amc.log' --def unsorted=y subtitles=en clean=y '"ut_dir=%F"' '"ut_kind=multi"' '"ut_title=%N"' '"ut_label=%L"' '"seriesFormat=E:\TV Shows\{n}\{''Season ''+s}\{s00e00} - {t}"' '"exec=@\path\to\args.txt"'}" 21 | ``` 22 | 23 | ---- 24 | 25 | **Date: 15 Aug, 2017:** 26 | I was thinking of making notifications better. Before this, I'd receive a notification for every file processed, meaning, if a series torrent with `n` number of episodes was processed, I'd receive `n` number of notifications. 27 | 28 | This was really annoying when a single season had more than 8 episodes. So I made used of telegram's small blogging platform telegra.ph to make this simple. The `Episode Name`, and the `Series Title` would be written to a file after every torrent completion, and then my `Notification_Processor.py` python script would run, and if more than 1 episode were processed, it'd submit those file names to telegra.ph with the `Series Title` as the article's title, and send that link to me via the bot. 29 | 30 | Telegram has this interesting feature called **Instant View** which lets you open articles from telegra.ph or [any site with a template](https://instantview.telegram.org/) to open articles instantly inside the app itself. 31 | 32 | Since I had to execute `Notification_Processor.py` after **Filebot** was done, couldn't run my python script from **--def exec** anymore. Since qBittorrent's `Execute After Torrent Completion` feature executes commands on a normal Command Prompt, I had to write the filebot script in such a way that it'd be written in Windows CMD, but executed in Powershell. This is the new Filebot script you feed into qBittorrent's `Run External Program After Torrent Completion` in Tools > Options > Downloads: 33 | 34 | ``` 35 | powershell -Command "&{&'filebot.launcher' -script fn:amc --output '"E:\\"' --action 'move' --conflict 'skip' -non-strict --log-file 'amc.log' --def unsorted=y subtitles=en clean=y '"ut_dir=%F"' '"ut_kind=multi"' '"ut_title=%N"' '"ut_label=%L"' '"seriesFormat=E:\TV Shows\{n}\{''Season ''+s}\{s00e00} - {t}"' '"exec=@\path\to\args.txt"'}"; "&{&'\path\to\Notification_Processor.py'}" 36 | ``` 37 | Replace `E:\` with your own directory/drive as usual. 38 | 39 | This is the new `args.txt`: 40 | ``` 41 | echo {quote("$n")} | Out-File -Encoding UTF8 SeriesName.txt; echo {quote("${any{episode; s00e00 + ' - ' + t}{movie}}")} | Out-File -Encoding UTF8 EpisodeDet.txt -append 42 | ``` 43 | **NOTE:** I haven't worked out anything for Pushbullet so far. For future though, I'd probably send the telegra.ph article link as the message content, even though it doesn't have an Instant View. 44 | 45 | ---- 46 | 47 | **Date: 08 May, 2017:** 48 | Since the release of Filebot v4.7.7, rednoah has changed the way `--def exec="@path/to/exec-format.txt"` works. It now uses Powershell to pass media info to the external scripts rather than CMD (Command Prompt) on windows. This makes it behave closer to Bash in Linux and according to rednoah, less code to write and maintain. This made me change my notification scripts because of the change in syntax. 49 | 50 | _Filebot version_: `v4.7.7` and higher (this is tested on `v4.7.9`) 51 | 52 | Here's the new `args.txt` for Pushbullet & Telegram: 53 | 54 | 1. **Pushbullet:** 55 | 56 | ``` 57 | pushbullet.py -key YOUR_API_KEY -title {quote("*$n*")} -message {quote("The $type _ ${any{episode; s00e00 + ' - ' + t}{movie}} _ is ready.")} 58 | ``` 59 | 60 | 2. **Telegram:** 61 | 62 | ``` 63 | telegram.py -t {quote("*$n*")} -m {quote("The $type _ ${any{episode; s00e00 + ' - ' + t}}{movie}} _ is ready.")} 64 | ``` 65 | 66 | ---- 67 | 68 | **Date: 07 Jan, 2017:** 69 | After KickAss Torrents went down on July 20 last year, I had to make do with ExtraTorrent's RSS Feeds. The feeds would work fine if they utilized HTTPS only functionality which ExtTorrents didn't, because my ISP blocked access to HTTP versions of most torrent sites, so the past six months have been a chore and mildly inconvenient for my setup. Also, qBit's ability to auto execute scripts upon torrent completion didn't work after v3.3.4 that is, until someone on Github recently taught me a solution to the problem. So here's a new script: 70 | 71 | *NOTES:* Use RSS Feeds from zooqle.com now. They are HTTPS only and hence RSS Feed Downloader works seamlessly with it. 72 | The `args.txt` file contains the same arguments as with the previous versions, which is given in the below log (DATE:19 MAY). 73 | 74 | **EDIT (11 MAR, 2017):** I now use a Telegram bot for push notifications, instead of Pushbullet. 75 | 76 | SCRIPT: 77 | ``` 78 | filebot -script fn:amc --output "E:/" --action move --conflict auto -non-strict --log-file amc.log --def unsorted=y subtitles=en clean=y "ut_dir=%F" 79 | "ut_kind=multi" "ut_title=%N" "ut_label=%L" "seriesFormat=E:/TV Shows/{n}/{'Season '+s}/{s00e00} - {t }" exec="@E:\New\args.txt" 80 | ``` 81 | 82 | ---- 83 | 84 | **Date: 12 Jul, 2016:** 85 | After more than a month of using uTorrent, I hardly found myself using their "uTorrent Remote" feature as the Android version of the app hasn't even been updated since Dec,2013 and it's very slow and infested with bugs, not to mention the bad history uTorrent has with malwares. So here I am, back to qBittorrent v3.3.4. I've added some of the modifications from the utorrent script to my last qBittorrent script so that I can have the same functionality on a more reliable environment. 86 | 87 | *NOTES:* The `args.txt` file contains the same arguments as with the previous versions, which is given in the below log (DATE:19 MAY). 88 | 89 | SCRIPT: 90 | ``` 91 | "C:\Program Files\FileBot\filebot.launcher.exe" -script fn:amc --output "path/to/media" --action move --conflict auto -non-strict --log-file amc.log 92 | --def unsorted=y subtitles=y clean=y "ut_dir=%F" "ut_kind=multi" "ut_title=%N" "ut_label=%L" "seriesFormat=S:/TV Shows/{n}/{'Season '+s}/{s00e00} - {t }" 93 | exec="@E:/path/to/args.txt" 94 | ``` 95 | 96 | ---- 97 | ## μtorrent 98 | **Date: 19 May, 2016:** 99 | I wasn't satisfied with the previous Pushbullet because there were not dynamic. The Pushbullet message preset in the previous log's script is only good enough for TV Series. But when it comes to Movies, it's not the optimal choice. Also, writing long lines with multiple quotations in them can be pretty confusing and a mess to debug because of escape characters, so I put the pushbullet message line inside a text file and called it with: `--def "exec=@path/to/args.txt"` for ease of access and understanding. 100 | 101 | **USAGE:** Look at the below log's 'USAGE' section. 102 | 103 | *NOTES:* This is the pushbullet message line (NOW OUTDATED. REFER TO LOG OF **8 MAY, 2017**): 104 | ``` 105 | pushbullet -apikey "apikey" -title "{movie}{episode; n}" -message "{movie; 'The movie'}{episode; s00e00}{episode; ' - '}{episode; t} is ready." 106 | ``` 107 | 108 | SCRIPT: 109 | ``` 110 | filebot -script fn:amc --output "E:/" --action move --conflict auto -non-strict --log-file amc.log --def unsorted=y clean=y subtitles=en 111 | "ut_file=%F" "ut_dir=%D" "ut_kind=multi" "ut_title=%N" "ut_label=%L" --def "seriesFormat=/TV Shows/{n}/{'Season '+s}/{s00e00} - {t }" 112 | --def excludeList=amc.txt --def "exec=@path/to/args.txt" 113 | ``` 114 | 115 | ---- 116 | 117 | **Date: 12 May, 2016:** 118 | The native pushbullet feature can't be modified to change the display message so I asked on the Filebot forum for a way and the dev said I could either make a donation to him and get it done by him or run an external program which would handle Pushbullet messages from CLI so I opted for running an external program to handle the pushbullet alerts. I'm using an unofficial CLI tool built by [dendory.](https://github.com/dendory/pushbullet_cli) 119 | It basically allows me to modify the pushbullet message. 120 | 121 | **USAGE:** Add the `pushbullet.exe in` `./Tools` or your System32 dir (for testing only. Add it to a folder which is in your env. path) and use the below script. 122 | 123 | SCRIPT: 124 | ``` 125 | filebot -script fn:amc --output "E:/" --action move --conflict auto -non-strict "E:/New" --log-file amc.log 126 | --def unsorted=y clean=y subtitles=en --def "seriesFormat=/TV Shows/{n}/{'Season '+s}/{s00e00} - {t }" 127 | --def excludeList=amc.txt 128 | --def "exec=pushbullet -apikey \"apikey\" -title \"New episode of {n} is here! \" -message \"{s00e00} - {t} has been downloaded.\"" 129 | ``` 130 | 131 | ---- 132 | 133 | **Date: 07 May, 2016:** 134 | μTorrent's Remote view feature caught my eye. I could the progress of my torrents remotely and also add/remove torrents while away from home. But, μTorrent's RSS Downloader had caused me issues in the past which is the reason I switched from μTorrent to qBittorent. But unfortunately, qBittorrent didn't have remote feature similar to μTorrent. Fortunately, with a little bit of help from reddit, I forced myself to try it one more time but it didn't work until several tries. Here's the script I'm using currently. 135 | 136 | This script does all the things my previous qBittorrent script used to. Apart from that, now it also sends a Pushbullet notification each time a torrent is finished processing by Filebot and it's accompanied by a HTML file that gives a summary of changes made. 137 | 138 | **USAGE:** Add this below script to μtorrent to execute it after a torrent is finished. 139 | `μtorrent > Preferences > Advanced > Run Program > Run this program when a torrent finishes` 140 | 141 | *NOTE:* 142 | * ALWAYS USE Forward-slash (/) WHEN DENOTING FOLDERS\FILES IN THE SCRIPT TO AVOID CONFLICTS. 143 | * Change `apikey` & path/to/media with your own Pushbullet apikey and media path respectively. 144 | 145 | SCRIPT: 146 | ``` 147 | filebot -script fn:amc --output "path/to/media" --action move --conflict skip -non-strict --log-file amc.log --def unsorted=y clean=y subtitles=en 148 | "ut_file=%F" "ut_dir=%D" "ut_kind=multi" "ut_title=%N" "ut_label=%L" --def "seriesFormat=/TV Shows/{n}/{'Season '+s}/{s00e00} - {t }" 149 | --def excludeList=amc.txt --def pushbullet=apikey 150 | ``` 151 | 152 | ---- 153 | 154 | # qBittorrent 155 | **Date: 29 Apr, 2016:** 156 | The last script gave me another issue. It would run renaming for all the folders present in the directory and messing up with active/incomplete downloads. This should hopefully solve all problems for now. 157 | 158 | SCRIPT: 159 | ``` 160 | filebot -script fn:amc --output "/path/to/media/" --action move 161 | --conflict skip -non-strict --log-file amc.log 162 | --def unsorted=y clean=y subtitles=en "ut_dir=%F" "ut_kind=multi" 163 | "ut_title=%N" "ut_label=%L" --def "seriesFormat=/TV Shows/{n}/{'Season '+s}/{s00e00} - {t }" --def excludeList=amc.txt 164 | ``` 165 | 166 | ---- 167 | **Date: 22 Apr, 2016:** 168 | Hopefully, this should be the last modification I'll be making in a long time. I finally got the subtitles to download properly. Fixed the error with Seasons folder being named in the manner of "Season 02". Now it can handle multiple files pretty well, be it movies or tv show or both. Doesn't leave a Excludes.list after renaming and organizing. Also set it to *MOVE* the files rather than COPY them, and reduce disk space. Yes, that makes me a leecher. You can create symlinks/hardlinks to keep seeding them after moving them, I haven't tested them. This version also cleans the leftover folders with ease, making human intervention minimum. 169 | 170 | SCRIPT: 171 | ``` 172 | filebot -script fn:amc --output "E:/" --action move -non-strict "E:/New" 173 | --log-file amc.log --def "seriesFormat=/TV Shows/{n}/{'Season '+s}/{s00e00} - {t 174 | }" --def subtitles=en clean=y --conflict skip 175 | ``` 176 | 177 | ---- 178 | **DATE: 21 APR, 2016:** 179 | The new script utilizes filebot's native AMC (Automated Media Center) groovy script to automate the process. Moreover, the process is more fluent with the script executing right after a new torrent is finished downloading. I've got to add the feature to fetch subtitles (it's really easy, --get-subtitles). The script renames and moves the renamed file to the movies folder. 180 | NOTE: For the purpose of convenience, movies are now directly stored in the "Movies" folder and not in ".\Movies\Blu-Ray & DVDs\Hollywood". 181 | 182 | **USAGE:** Add this below script to qBittorrent to execute it after a torrent is finished. 183 | ```qBittorrent > Tools > Downloads > Run external program on torrent completion.``` 184 | 185 | *NOTE:* ALWAYS USE Forward-slash (/) WHEN DENOTING FOLDERS\FILES IN THE SCRIPT TO AVOID CONFLICTS. 186 | 187 | **!NOW OBSOLETE!** 188 | 189 | SCRIPT: 190 | ``` 191 | filebot -script fn:amc --output "/downloadsFolder/" --action symlink --conflict skip -non-strict 192 | --log-file amc.log unsorted=n music=n artwork=n "ut_dir=%F" "ut_kind=multi" "ut_title=%N" 193 | "ut_label=%L" --def "seriesFormat={s00e00} - {t}" 194 | ``` 195 | 196 | ---- 197 | **DATE: 19 APR, 2016:** 198 | USAGE: Save this as a batch file in the folder where new media is downloaded. Add the batch to Task Scheduler's list to execute it at every startup. 199 | 200 | **!NOW OBSOLETE!** 201 | 202 | SCRIPT: 203 | ``` 204 | @ECHO OFF 205 | cls 206 | ECHO #############RENAME############# 207 | 208 | ECHO Renaming in progress... 209 | @ECHO OFF 210 | filebot -rename 211 | ``` 212 | 213 | ---- -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Kanishk Singh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Notification_Processor.py: -------------------------------------------------------------------------------- 1 | #! python3 2 | # -*- coding: utf-8 -*- 3 | import logging 4 | from telegraph_post import telegraph_submit 5 | from telegram import telegram 6 | 7 | logger = logging.getLogger() 8 | handler = logging.FileHandler('E:/New/config/notifications.log') #Use absolute paths 9 | formatter = logging.Formatter('%(asctime)s %(name)-12s %(levelname)-8s %(message)s') 10 | handler.setFormatter(formatter) 11 | logger.addHandler(handler) 12 | logger.setLevel(logging.DEBUG) 13 | 14 | __author__ = 'Kanishk Singh (Arion Miles)' 15 | __license__ = "MIT" 16 | 17 | def line_no(fname): 18 | '''Count number of lines in a text file.''' 19 | i =- 1 20 | with open(fname, encoding='utf-8-sig') as f: 21 | for i, l in enumerate(f): 22 | pass 23 | return i + 1 24 | 25 | def FileBot(): 26 | with open("E:/New/config/SeriesName.txt", 'r', encoding='utf-8-sig') as sr: #Use absolute paths 27 | seriesTitle = sr.read().strip('\n') 28 | logger.debug('Reading %s' % sr) 29 | with open("E:/New/config/EpisodeDet.txt", 'r', encoding='utf-8-sig') as file: #Use absolute paths 30 | episodeNames = file.read() 31 | logger.debug('Reading %s' % file) 32 | 33 | #Send message depending upon number of files processed (checked with number of lines) 34 | logger.debug('Checking number of files processed...') 35 | if line_no("E:/New/config/EpisodeDet.txt") > 2: #Use absolute paths 36 | logger.debug('More than one file processed. Sending to Telegra.ph \n \n') 37 | telegraph_submit(seriesTitle, episodeNames) 38 | else: 39 | logger.debug('One file processed. Sending directly. \n \n') 40 | seriesTitle = '' + seriesTitle + '' 41 | telegram(seriesTitle, episodeNames) 42 | 43 | #Empty File contents 44 | logger.debug('Clearing contents of the text files.') 45 | with open("E:/New/config/SeriesName.txt", 'w', encoding='utf-8-sig') as sr: #Use absolute paths 46 | pass 47 | with open("E:/New/config/EpisodeDet.txt", 'w', encoding='utf-8-sig') as file: #Use absolute paths 48 | pass 49 | 50 | if __name__ == '__main__': 51 | FileBot() 52 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # Torrent Automation 2 | **Author:** Arion Miles 3 | 4 | ## How it works: 5 | I use Filebot's [AMC script](https://www.filebot.net/forums/viewtopic.php?t=215) for qBittorrent which automatically executes once a torrent has finished downloading, then the filebot script sorts them out into Movies/TV series and on the basis of that renames them into `SxxExx - Title` format and puts them into their respective `SeriesTitle/Season xx` folders. 6 | 7 | For movies, it simply renames them to `MovieName (YEAR)` format and puts them in a folder of the same name. 8 | 9 | Then I receive a Pushbullet/Telegram notification telling me if a Movie or a Series (with episode number and title) is ready and my [Plex](https://plex.tv) library is automatically updated. 10 | 11 | 12 | ## Folder Structure: 13 | ``` 14 | +---Web 15 | 16 | +---Movies 17 | 18 | +---New 19 | | +---config 20 | | | .Logs.lnk (Filebot AMC Log file) 21 | | | args.txt 22 | | | creds.ini 23 | | | EpisodeDet.txt 24 | | | Notification_Processor.py 25 | | | Manual.ps1 26 | | | SeriesName.txt 27 | | | telegram.py 28 | | | telegraph_post.py 29 | | 30 | 31 | +---TV Shows 32 | ``` 33 | Consists of 4 parts: 34 | * [Torrent Client](#torrent-client) 35 | * [FileBot](#filebot) 36 | * [RSS Feeds](#rss-feeds) 37 | * [Notifications](#notifications) 38 | 39 | ## Torrent Client 40 | You can use any torrent client, but bear in mind that different clients have minor changes in the Filebot script depending upon their supported parameters. I'm using [qBittorrent](https://github.com/qbittorrent/qBittorrent). [Look at this guide](https://www.filebot.net/forums/viewtopic.php?t=215) from Rednoah on Filebot forums to choose proper script for your client. 41 | 42 | For qBittorrent, paste the script here: 43 | Tools 🡪 Options (Alt + O) 🡪 Downloads 🡪 Run external program on torrent completion 44 | 45 | ## Filebot 46 | >Filebot is the ultimate tool for organizing and renaming your movies, tv shows or anime, and music well as downloading subtitles and artwork. It's smart and just works. 47 | 48 | \- [FileBot.net](http://www.filebot.net/) 49 | 50 | This is my current script ([qBittorrent](https://www.filebot.net/forums/viewtopic.php?t=215#p9774)). 51 | 52 | ``` 53 | powershell -Command "&{&'filebot.launcher' -script fn:amc --output '"E:\\"' --action 'move' --conflict 'skip' -non-strict --log-file 'amc.log' --def unsorted=y subtitles=en clean=y '"ut_dir=%F"' '"ut_kind=multi"' '"ut_title=%N"' '"ut_label=%L"' '"seriesFormat=E:\TV Shows\{n}\{''Season ''+s}\{s00e00} - {t}"' '"exec=@\path\to\args.txt"'}" 54 | ``` 55 | 56 | An extensive log of filebot scripts I went through is present in [Filebot_Logs](../master/Filebot_Logs.MD) file. See the logs to see why I chose the current script. 57 | 58 | **NOTE**: The TVDb API v1, which is used by Filebot for fetching Series info [will be disabled](https://forums.thetvdb.com/viewtopic.php?f=3&t=36557) on **1st October 2017** in favour of [TVDb API v2.](https://api.thetvdb.com/swagger) 59 | 60 | As a result, all older versions of Filebot cannot be used for Series renaming after 1st Oct. 2017. Therefore, you must update Filebot to the latest version from Filebot.net 61 | 62 | The newer versions of Filebot are paid for Windows, were always paid for Mac OS, and are free as of now for Linux. The dev works very hard on the software and provides excellent support on [his Forum](https://www.filebot.net/forums/), which helped me make this guide in such detail for everyone. If you cannot afford it, the dev is considerate enough to upload the binaries to [SourceForge](https://sourceforge.net/projects/filebot/files/filebot/) where you can download the installer for free. But please consider donating to him for his hardwork and prompt support. 63 | 64 | ## RSS Feeds 65 | 1. Get a RSS feed link from your favourite Torrent Aggregator (I use Zooqle) for the desired tv show from a particular uploader of your choice. 66 | 67 | Use the following search parameters: 68 | 69 | Search > `{TVSeriesName} {quality} {suffixes} DesiredUser` 70 | 71 | where {suffixes} = LOL/Xvid-FUM/DIMENSION/RARBG. Leave it blank if your search with `seriesName`, 72 | `quality` & `DesiredUser` return satifactory results. 73 | 74 | 2. Add this link to your RSS subscription's list. 75 | 76 | 3. Set a new rule in the RSS Downloader for your particular TV Series (or user, in the case of Movies) and set it to contain a specific keyword and set the Episode filter according to the season and no. of episodes it has. Apply this rule to your particular subscribed feed. 77 | 78 | 4. Test it multiple times to make sure you're doing it right. 79 | 80 | ## Notifications 81 | There are two main ways to receive push notifications on your mobile devices: Pushbullet & Telegram (Filebot supports e-mail notifications by default. Check out `--def mailto=email ` and `--def mail=host:port:from[:username:password]`). 82 | First, create a text file in the torrent download directory (ease of access/debugging). 83 | 84 | e.g: My download dir is `E:\New` and the file is named `args.txt` and its path is `E:\New\args.txt`. 85 | This is what the `--def exec="@path/to/args.txt"` in the above script is for. 86 | 87 | The format of the push notification is as follows: 88 | 89 | **Movies:** 90 | ``` 91 | Title: Doctor Strange (2016) 92 | ``` 93 | **TV Shows:** 94 | ``` 95 | Title: Game of Thrones 96 | Message: S06E09 - The Battle of Bastards 97 | ``` 98 | #### Pushbullet: 99 | ---- 100 | For pushbullet, you need the API key, and [a python script](https://raw.githubusercontent.com/dendory/scripts/091692bb07c685f5222e8d1f9e783db5b82c4f9f/pushbullet.py) made by Dendory. You can get the [Pushbullet API Key here](https://www.pushbullet.com/#settings/account). 101 | 102 | Now, in `args.txt` paste the below line: 103 | ``` 104 | pushbullet.py -key YOUR_API_KEY -title {quote("* ${any{episode; n}{movie}} *")} -message {quote("${episode; s00e00 + ' - ' + t}")} 105 | ``` 106 | 107 | Add this script to your environment variable OR a folder which is in your environment variable (Except C:\Windows\System32, never do that.) 108 | 109 | #### Telegram: 110 | ---- 111 | For Telegram, you can use a script I made, [available here](https://github.com/ArionMiles/Filebot-To-Telegram/). Look at the instructions on the git repo. Be sure to edit the `creds.ini` with your Bot's `token` and `CHAT_ID`. 112 | 113 | In `args.txt` paste the below line: 114 | 115 | ``` 116 | echo {quote("${any{episode; n}{movie}}")} | Out-File -Encoding UTF8 E:\New\config\SeriesName.txt; echo {quote("${episode; s00e00 + ' - ' + t}")} | Out-File -Encoding UTF8 E:\New\config\EpisodeDet.txt -append; Notification_Processor.py 117 | ``` 118 | 119 | also create a `SeriesName.txt` & `EpisodeDet.txt` in the same directory. 120 | 121 | ## Tips & Common Issues 122 | 1. If you're on Windows and cannot run the telegram/pushbullet script from the command line after adding it to env. variables, do the following: 123 | 124 | Regedit > `HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command` 125 | 126 | And change the value from : `"C:\Python27\python.exe" "%1"` 127 | 128 | To: `"C:\Python27\python.exe" "%1" %*` 129 | 130 | Similarly, set `HKEY_CLASSES_ROOT\py_auto_file\shell\open\command` to the same value. 131 | 132 | **adjust the path to your specific Python version.** 133 | 134 | Read more about this [here.](http://eli.thegreenplace.net/2010/12/14/problem-passing-arguments-to-python-scripts-on-windows/) 135 | 136 | 2. Things will hardly go right in the first run, it took me 20 days to get the basic setup working as intended. So it's handy to have the Filebot's AMC log file close to your working directory. As for me, I keep it in my downloads folder (which I've named NEW). The file logs every step Filebot takes while processing new downloads and throws errors which are useful for troubleshooting, it still helps me when things don't go as planned. 137 | 138 | The Filebot AMC log can be found at `C:\Users\%USERPROFILE%\AppData\Roaming\FileBot\logs\amc.log` on Windows. 139 | Create a shortcut to this file in your downloads directory. 140 | 141 | 3. Create a manual.ps1/manual.sh file in your downloads dir with the Filebot script with a little modification. Sometimes Filebot may fail to process the file, citing the file is already in use by another process. In that case, this powershell/bash file will help to manually complete the task. 142 | 143 | For example, for my current script, I'd paste the below **as a single line** into a text file and save it as `Manual.ps1` or `Manual.sh` in the downloads directory. 144 | ``` 145 | filebot -script fn:amc --output "E:/" --action move --conflict skip -non-strict "E:/New" --log-file amc.log --def "seriesFormat=/TV Shows/{n}/{'Season '+s}/{s00e00} - {t }" --def "exec=@E:/New/config/args.txt" ; .\Notification_Processor.py 146 | ``` 147 | Change the output/dir, path/to/args.txt, and "E:/New" with what you put in the filebot script above. For testing/trial purposes, just paste already processed file in your downloads directory, rename it in a format the torrent uploaders do, like `Netflix.Daredevil.S02E04.x264.720p.aac` and run the batch file from command line. You'll be able to see every error easily, also the logs for this will be stored in the same `amc.log` file. 148 | 149 | **Note:** Read about [enable execution of PowerShell scripts.](https://www.howtogeek.com/106273/how-to-allow-the-execution-of-powershell-scripts-on-windows-7/) 150 | 151 | 4. If even on torrent completion, Filebot doesn't run the script, you must make sure all the three main components, i.e., qBittorrent, Java JRE, and Filebot installed are of similar system architecture (i.e., either all 32-bit or 64-bit depending on your system architecture). 152 | 153 | 5. Newer filebot versions use PowerShell to execute the `--def exec="@path/to/file"` hooks, meaning executing Python scripts with PowerShell leads to opening new Python window from PowerShell and then executing our script. This can be distracting for users if they download in the background and while processing the file, they see a shell pop-up on their screens. If you'd like to do this silently, then append `;.py` at the end of your `PATHTEXT` in your Environment Variables (for help, [see this answer on StackOverflow](https://superuser.com/a/437853)). Now PowerShell will execute Python files from within itself. 154 | 155 | ## Further Reading 156 | 157 | Read [this](https://www.filebot.net/forums/viewtopic.php?t=215) comprehensive guide on Filebot arguments/parameters by Rednoah (Filebot dev) to further improve and customize your script according to your needs. 158 | 159 | ## CONTRIBUTING 160 | 161 | This setup is largely platform agnostic, but there might be a few times where certain things don't work for other systems. In that case, fork the repo, add instructions for specific OS, and send a PR. 162 | 163 | For issues, enhancements, feature requests, use the issue tracker. --------------------------------------------------------------------------------