Author Topic: SickBeard detect unfinished downloads  (Read 2772 times)

0 Members and 1 Guest are viewing this topic.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
SickBeard detect unfinished downloads
« on: December 30, 2015, 02:08:46 AM »
Sorry for the delayed response,

I'm working on a command that looks at Sickbeard snatched history and then checks each show that is listed in the snatched history to see if they still contain any snatched episodes, then if any of the shows still have snatched episodes it will send an email with a list of the shows that have snatched episodes 

the first logic block in the second command (Sickbeard compare) is where the goto action or a loopblock with an if statement would come in and would allow me to build this all into one command


Sickbeard Check and compare
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.9-->
<commandGroup open="True" name="Sickbeard Check and Compare" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="401" name="Sickbeard Snatched and compare" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.1.10:8081/api/APIKEY HERE/?cmd=history&amp;type=snatched&amp;limit=10</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>id":\s(\d+)</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>TVid{i}</param>
        <param>{Match.{i}.1}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>name":\s"(.*?)"</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>TVname{i}</param>
        <param>{Match.{i}.1}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Snatched:</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>LC</param>
        <param>0</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>Snatched</param>
        <param><![CDATA[ ]]></param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <loop>
      <loopParams>
        <from>1</from>
        <to>10</to>
      </loopParams>
      <loopActions>
        <action>
          <cmdType>Scrape</cmdType>
          <params>
            <param>http://192.168.1.10:8081/api/APIKEY HERE/?cmd=show.stats&amp;tvdbid={var.TVid{j}}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.RegExSingle</cmdType>
          <params>
            <param>snatched":\s{.*?"total":\s(\d+).*?}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>TVsnatched{j}</param>
            <param>{Match.1.1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.AddText</cmdType>
          <params>
            <param>{Var.TVname{j}} - TVdbID{Var.TVid{j}}  Snatched: {var.TVsnatched{j}}</param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.TriggerEvent</cmdType>
          <params>
            <param>Snatched</param>
            <param>{Var.TVname{j}}</param>
            <param>{var.TVsnatched{j}}</param>
            <param>{Var.TVid{j}}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </loopActions>
    </loop>
  </command>
  <command id="490" name="Sickbeard compare" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>result={Var.LC}+1</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>LC</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>0&amp;&amp;{2}</ifParams>
      <then>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>Snatched</param>
            <param>{Var.Snatched} &lt;br&gt;&lt;br&gt;&lt;a href="http://ip:port/home/displayShow?show={3}"&gt;{1}&lt;/a&gt;      </param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.LC}&amp;&amp;10</ifParams>
      <then>
        <action>
          <cmdType>SMTP.Send</cmdType>
          <params>
            <param>Email@here.com</param>
            <param>System Check update</param>
            <param>These Shows still have Snatched Episodes &lt;br&gt;&lt;br&gt;{Var.Snatched}</param>
            <param />
            <param>True</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>Snatched</event>
  </command>
</commandGroup>

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: SickBeard detect unfinished downloads
« Reply #1 on: December 30, 2015, 10:42:57 AM »
Is the ultimate purpose of this command to send you a list of shows which have started downloading but have not yet finished downloading?

If that's not correct, can you please explain what the goal is in non-technical terms.

Thanks

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: SickBeard detect unfinished downloads
« Reply #2 on: December 30, 2015, 11:10:08 AM »
sorry about that,

the ultimate goal is to email a list of episodes that where grabbed, but for some reason they did not finish downloading (could be a bad file pack or bad internet...)


jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: SickBeard detect unfinished downloads
« Reply #3 on: December 30, 2015, 12:03:49 PM »
OK.  And does this command work, as is?

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: SickBeard detect unfinished downloads
« Reply #4 on: December 30, 2015, 12:32:51 PM »
yes it is, :D

I still need to add another if statement so a blank email isn't sent when all episodes downloaded properly,

I'll share once I have it finished

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: SickBeard detect unfinished downloads
« Reply #5 on: December 30, 2015, 12:38:43 PM »
Cool.  Meanwhile I am working on an alternate method that will hopefully be a bit more efficient and bullet-proof.  I'll let you know when I have something functional.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: SickBeard detect unfinished downloads
« Reply #6 on: December 30, 2015, 01:05:50 PM »
would you like me start a new thread with the finished command?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: SickBeard detect unfinished downloads
« Reply #7 on: December 30, 2015, 01:31:42 PM »
No, it's OK I split this to a new topic starting with your original command XML.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: SickBeard detect unfinished downloads
« Reply #8 on: December 30, 2015, 02:38:47 PM »
in this group it checks the last 10 snatched items in Sickbeard and then checks each TV show listed to see if they still have episodes marked as snatched,

if any of the shows still have episodes marked as snatched it will send an email with hyperlinks for each show (the hyperlinks will only work if you are connected to the same network as your Sickbeard software)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.9-->
<commandGroup open="True" name="Sickbeard Check and Compare" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="389" name="Sickbeard Snatched and compare" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://192.168.1.10:8081/api/API KEY HERE/?cmd=history&amp;type=snatched&amp;limit=10</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>id":\s(\d+)</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>TVid{i}</param>
        <param>{Match.{i}.1}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>name":\s"(.*?)"</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>TVname{i}</param>
        <param>{Match.{i}.1}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Snatched:</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>LC</param>
        <param>0</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>Snatched</param>
        <param><![CDATA[ ]]></param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <loop>
      <loopParams>
        <from>1</from>
        <to>10</to>
      </loopParams>
      <loopActions>
        <action>
          <cmdType>Scrape</cmdType>
          <params>
            <param>http://192.168.1.10:8081/api/API KEY HERE/?cmd=show.stats&amp;tvdbid={var.TVid{j}}</param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.RegExSingle</cmdType>
          <params>
            <param>snatched":\s{.*?"total":\s(\d+).*?}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>TVsnatched{j}</param>
            <param>{Match.1.1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.TriggerEvent</cmdType>
          <params>
            <param>Snatched</param>
            <param>{Var.TVname{j}}</param>
            <param>{var.TVsnatched{j}}</param>
            <param>{Var.TVid{j}}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </loopActions>
    </loop>
  </command>
  <command id="494" name="compare" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PY.ExecString</cmdType>
      <params>
        <param>result={Var.LC}+1</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>LC</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>0&amp;&amp;{2}</ifParams>
      <then>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>Snatched</param>
            <param>{Var.Snatched} &lt;br&gt;&lt;br&gt;&lt;a href="http://192.168.1.10:8081/home/displayShow?show={3}"&gt;{1}&lt;/a&gt;      </param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.LC}&amp;&amp;10</ifParams>
      <then />
      <else>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.Snatched}&amp;&amp; </ifParams>
      <then>
        <action>
          <cmdType>TTS.SpeakSync</cmdType>
          <params>
            <param>it appears that all episodes where downloaded correctly</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>it appears that you have some failed downloads, I emailed you a list of shows that contain snatched episodes</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>SMTP.Send</cmdType>
          <params>
            <param>YOUR EMAIL HERE</param>
            <param>Sick Beard update</param>
            <param>list of failed episodes {Var.Snatched}</param>
            <param />
            <param>True</param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
      </else>
    </if>
    <event>Snatched</event>
  </command>
</commandGroup>

in the first command there are 2 disabled actions you will need to change the IP addresses and port numbers in both actions to your sickbeard IP and port number, where it says "API KEY HERE" you will need to add your sickbeard API Key.

in the second command there are 2 disabled actions you will need to change the IP address and Port number to match your sickbeard IP and Port number, in the second action where is says "YOUR EMAIL HERE" you will need to add the email address you want the list sent to.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: SickBeard detect unfinished downloads
« Reply #9 on: December 30, 2015, 06:52:53 PM »
For what it's worth, here is my version.

The implementation is quite different.  Functionally it is similar but in mine it will only scan each show once.  The second command keeps a list of which shows it has already scanned and if asked to scan a show that is already in the list it will use VC.StopMacro right away.

One thing that I noticed on yours PegLeg which I think is wrong, is that your initial regex for the show IDs should be more specific about which ID you want, because you will probably be getting 2 ids for each history item.  Then you are doing a separate regex for the name which won't line up properly with the show Ids because of this.  id" will match both indexerid and tvdbid.

I mostly make use of VC.SetEventTimer to call a command which checks each individual show.  I need to use a timer instead of VC.TriggerEvent (or Results.MatchToEvent) in order to avoid the regEx calls in the second command from overwriting the matches in the first command.  This is one thing I am unhappy about in VC.  Ideally each command should have its own local matches.  One day...

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.4-->
<commandGroup open="True" name="Sickbeard Check (JITTERJAMES)" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="413" name="++Sickbeard  check history (JITTERJAMES)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>SBEmailBody</param>
        <param>These shows require attention:</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>SBKey</param>
        <param>http://NAS_ADDRESS:PORT/api/YOUR_APIKEY_HERE/</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>SbShowsProcessed</param>
        <param>shows processed: </param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Checking Shows for snatched episodes:</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>{var.SBKey}?cmd=history&amp;type=snatched&amp;limit=10</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>"indexerid":\s(\d+)   [^\{]*?  "show_name":\s"(.*?)",</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <loop>
      <loopParams>
        <from>1</from>
        <to>{#M}</to>
      </loopParams>
      <loopActions>
        <action>
          <cmdType>VC.Pause</cmdType>
          <params>
            <param>200</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>3</param>
            <param>SB.CheckShowSnatched</param>
            <param>{Match.{j}.1}</param>
            <param>{Match.{j}.2}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </loopActions>
    </loop>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>3500</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>SMTP.SendAsync</cmdType>
      <params>
        <param>YOUR_EMAIL_ADDR_HERE</param>
        <param>Unfinished downloads?</param>
        <param>{Var.SBEmailBody}</param>
        <param />
        <param>True</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
  </command>
  <command id="491" name="Sickbeard check each show ID  (JITTERJAMES)" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)Contains(B)</ifType>
      <ifParams>{Var.SbShowsProcessed}&amp;&amp;{1}</ifParams>
      <then>
        <action>
          <cmdType>VcAdvanced.Log</cmdType>
          <params>
            <param>Show was already processed: {1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>SbShowsProcessed</param>
            <param>{Var.SbShowsProcessed},{1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>{var.SBKey}?cmd=show.stats&amp;tvdbid={1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegExSingle</cmdType>
      <params>
        <param>snatched":\s{.*?"total":\s(\d+).*?}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>0&amp;&amp;{Match.1.1}</ifParams>
      <then>
        <action>
          <cmdType>OSD.AddText</cmdType>
          <params>
            <param>{2} requires attention</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>SBEmailBody</param>
            <param>{Var.SBEmailBody} &lt;br&gt;&lt;br&gt;&lt;a href="http://NAS_ADDRESS:PORT/home/displayShow?show={1}"&gt;{2}&lt;/a&gt;      </param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>VcAdvanced.Log</cmdType>
          <params>
            <param>{2} has no snatched episodes</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>SB.CheckShowSnatched</event>
  </command>
</commandGroup>
« Last Edit: December 30, 2015, 07:04:55 PM by nime5ter »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: SickBeard detect unfinished downloads
« Reply #10 on: December 30, 2015, 07:14:41 PM »
Oh ya, I've followed PegLeg's lead here and disabled the actions which require editing.  Any command that is red should be edited with your correct URLs and APIKEY and then the action loop should be changed from 0 to 1 to re-enable it.

Don't know if this is the best way to do things in general... If only there was a way to highlight text in action parameters.  I guess I need to fill out a feature request. ;)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: SickBeard detect unfinished downloads
« Reply #11 on: December 30, 2015, 11:17:27 PM »
Don't know if this is the best way to do things in general... If only there was a way to highlight text in action parameters.  I guess I need to fill out a feature request. ;)

I totally agree with you .. you should ask James about it ... he is very responsive to users requests :P
When Voice command gets tough, use hand gestures

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 499
  • Karma: 43
    • View Profile
Re: SickBeard detect unfinished downloads
« Reply #12 on: December 31, 2015, 01:31:56 PM »
I have to say you jinxed me, ;) I tested my command several times and no problems until you mentioned a problem and for some reason my command started to cycle 20 times every time, I tried to trouble shoot and had to extend the amount of lines shown in the VC window, and after doing that I couldn't for the life of me reproduce the problem, so I took a break and looked at your command to look at the regex and I noticed that you are looking for indexerid, but when I look at the output from the snatched history I don't have an indexerid only a tvdbid listed, here is part of the output

Code: [Select]
"data": [
        {
            "date": "2015-12-29 21:51",
            "episode": 13,
            "provider": "Sick Beard Index",
            "quality": "SD TV",
            "resource": "Marvels.Daredevil.S01E13.WEBRiP.x264-QCF",
            "resource_path": "",
            "season": 1,
            "show_name": "Marvel's Daredevil",
            "source": "nzb",
            "status": "Snatched",
            "tvdbid": 281662
        },

I like your regex idea better (I'll have to study some more regex guides) so with the output that I get from sickbeard this is the Regex pattern that works for me:

Code: [Select]
"show_name":\s"(.*?)"   [^\{]*?  "tvdbid":\s(\d+)
I like how you stop it from processing the same shows more then once, so I added in a fail safe that will notify with TTS and email if the Sickbeard sever isn't reachable as well,

so here's the command that I ended up with:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.9-->
<commandGroup open="True" name="Sickbeard Check and Compare" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="392" name="Sickbeard Snatched and compare" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>SBIP</param>
        <param>Put.SB.IP.Here:PORT</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>SBKEY</param>
        <param>API KEY HERE</param>
      </params>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://{Var.SBIP}/api/{Var.SBKEY}/?cmd=history&amp;type=snatched&amp;limit=10</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>"show_name":\s"(.*?)"   [^\{]*?  "tvdbid":\s(\d+)</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then />
      <else>
        <action>
          <cmdType>TTS.SpeakSync</cmdType>
          <params>
            <param>your Sick beard server was unreachable</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>SMTP.Send</cmdType>
          <params>
            <param>YOUR_EMAIL_HERE</param>
            <param>Sick Beard update</param>
            <param>SickBeard server was unreachable:&lt;br&gt;&lt;br&gt;&lt;a href="http://{Var.SBIP}/home/"&gt;Sickbeard server&lt;/a&gt;   </param>
            <param />
            <param>True</param>
          </params>
          <cmdRepeat>0</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>TVname{i}</param>
        <param>{Match.{i}.1}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>TVid{i}</param>
        <param>{Match.{i}.2}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>Snatched</param>
        <param><![CDATA[ ]]></param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <loop>
      <loopParams>
        <from>1</from>
        <to>10</to>
      </loopParams>
      <loopActions>
        <action>
          <cmdType>Scrape</cmdType>
          <params>
            <param>http://{Var.SBIP}/api/{Var.SBKEY}/?cmd=show.stats&amp;tvdbid={var.TVid{j}}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.RegExSingle</cmdType>
          <params>
            <param>snatched":\s{.*?"total":\s(\d+).*?}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.TriggerEvent</cmdType>
          <params>
            <param>SB.Snatched</param>
            <param>{Var.TVname{j}}</param>
            <param>{Match.1.1}</param>
            <param>{Var.TVid{j}}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </loopActions>
    </loop>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.Snatched}&amp;&amp; </ifParams>
      <then>
        <action>
          <cmdType>TTS.SpeakSync</cmdType>
          <params>
            <param>it appears that all episodes were downloaded correctly</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>it appears that you have some failed downloads, I emailed you a list of shows that contain snatched episodes</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>SMTP.Send</cmdType>
          <params>
            <param>YOUR_EMAIL_HERE</param>
            <param>Sick Beard update</param>
            <param>list of failed episodes:&lt;br&gt;{Var.Snatched}</param>
            <param />
            <param>True</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>SbIDProcessed</param>
        <param><![CDATA[ ]]></param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="473" name="compare" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)Contains(B)</ifType>
      <ifParams>{Var.SbIDProcessed}&amp;&amp;{3}</ifParams>
      <then>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>SbIDProcessed</param>
            <param>{Var.SbIDProcessed},{3}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>0&amp;&amp;{2}</ifParams>
      <then>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>Snatched</param>
            <param>{Var.Snatched} &lt;br&gt;&lt;br&gt;&lt;a href="http://{Var.SBIP}/home/displayShow?show={3}"&gt;{1}&lt;/a&gt;      </param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <event>SB.Snatched</event>
  </command>
</commandGroup>

In the first command you will need to add your Sickbeard IP and Port number to the first action and then add your API key to the second action, there are two different email actions as well that you will need to add your email to, then you will need to enable those actions by changing the 0 to a 1 on the right side of each action that is disabled

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: SickBeard detect unfinished downloads
« Reply #13 on: January 01, 2016, 01:32:07 PM »
Sorry.  I'm actually running SickRage on my Synology NAS.  The api is similar but not identical I guess.