this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Porla: Update workflows

+73 -71
+32 -28
cluster/apps/downloads/porla/app/workflows/move-completed.lua
··· 1 - local Workflow = require "porla.Workflow" 2 - local TorrentFinished = require "porla.triggers.TorrentFinished" 3 - local TorrentFlags = require "porla.actions.TorrentFlags" 4 - local TorrentMove = require "porla.actions.TorrentMove" 1 + local torrents = require("torrents") 2 + local workflows = require("workflows") 3 + local torrent = require("workflows.actions.torrent") 4 + local finished = require("workflows.triggers.torrent").finished 5 5 6 - return Workflow:new{ 7 - on = TorrentFinished:new{}, 8 - actions = { 9 - TorrentFlags:new{ 10 - unset = { 11 - "auto_managed" 12 - } 13 - }, 14 - TorrentMove:new{ 15 - path = function(ctx) 16 - local category = ctx.torrent.category or "default" 17 - if(category == "movies") then 18 - return "/media/downloads/porla/Movies" 19 - elseif(category == "sonarr") then 20 - return "/media/downloads/porla/Sonarr" 21 - elseif(category == "radarr") then 22 - return "/media/downloads/porla/Radarr" 23 - elseif(category == "default") then 24 - return "/media/downloads/porla/" 25 - elseif(ctx.torrent.save_path == "/media/downloads/porla/") then 26 - return "/media/downloads/porla/"..category 6 + function porla.init() 7 + workflows.add({ 8 + on = finished(), 9 + actions = { 10 + function(ctx, callback) 11 + local props = torrents.properties.get(ctx.torrent) 12 + props.flags = props.flags & ~torrents.flags.auto_managed 13 + torrents.properties.set(ctx.torrent, props) 14 + 15 + callback() 16 + end, 17 + torrent.move({ 18 + path = function(ctx) 19 + local category = ctx.torrent.category or "default" 20 + if(category == "movies") then 21 + return "/media/downloads/porla/Movies" 22 + elseif(category == "sonarr") then 23 + return "/media/downloads/porla/Sonarr" 24 + elseif(category == "radarr") then 25 + return "/media/downloads/porla/Radarr" 26 + elseif(category == "default") then 27 + return "/media/downloads/porla/" 28 + elseif(ctx.torrent.save_path == "/media/downloads/porla/") then 29 + return "/media/downloads/porla/"..category 30 + end 27 31 end 28 - end 32 + }) 29 33 } 30 - } 31 - } 34 + }) 35 + end
+41 -43
cluster/apps/downloads/porla/app/workflows/seeding-checker.lua
··· 1 - local Workflow = require "porla.Workflow" 2 - local Cron = require "porla.triggers.Cron" 3 - local TorrentRemove = require "porla.actions.TorrentRemove" 4 - local Log = require "porla.actions.Log" 1 + local workflows = require("workflows") 2 + local log = require("workflows.actions.log") 3 + local torrent = require("workflows.actions.torrent") 4 + local cron = require("workflows.triggers.cron") 5 5 6 - return Workflow:new{ 7 - on = Cron:new{ 8 - expression = "0 1-59/5 * * * *" 9 - }, 10 - filter = function(ctx) 11 - if ctx.torrent.category == "sonarr" and (ctx.torrent.is_seeding or ctx.torrent.is_finished) then 12 - local time = ctx.torrent.seeding_duration 13 - local ratio = ctx.torrent.ratio 14 - if ctx.torrent.tags:find("private") then 15 - -- 1 Hour 16 - if time >= 3600 and ratio >= 4 then 17 - return true 18 - -- 6 Hours 19 - elseif time >= 21600 and ratio >= 3 then 20 - return true 21 - -- 12 Hours 22 - elseif time >= 43200 and ratio >= 2 then 23 - return true 24 - -- 24 Hours 25 - elseif time >= 86400 and ratio >= 1.1 then 26 - return true 27 - -- 8 Days 1 Hour 28 - elseif time >= 694800 then 29 - return true 6 + function porla.init() 7 + workflows.add({ 8 + on = cron("0 1-59/5 * * * *"), 9 + filter = function(ctx) 10 + if ctx.torrent.category == "sonarr" and (ctx.torrent.is_seeding or ctx.torrent.is_finished) then 11 + local time = ctx.torrent.seeding_duration 12 + local ratio = ctx.torrent.ratio 13 + if ctx.torrent.tags:find("private") then 14 + -- 1 Hour 15 + if time >= 3600 and ratio >= 4 then 16 + return true 17 + -- 6 Hours 18 + elseif time >= 21600 and ratio >= 3 then 19 + return true 20 + -- 12 Hours 21 + elseif time >= 43200 and ratio >= 2 then 22 + return true 23 + -- 24 Hours 24 + elseif time >= 86400 and ratio >= 1.1 then 25 + return true 26 + -- 8 Days 1 Hour 27 + elseif time >= 694800 then 28 + return true 29 + end 30 + elseif ctx.torrent.tags:find("public") then 31 + return time >= 1800 32 + else 33 + return ratio >= 1.01 or time >= 694800 30 34 end 31 - elseif ctx.torrent.tags:find("public") then 32 - return time >= 1800 33 - else 34 - return ratio >= 1.01 or time >= 694800 35 35 end 36 - end 37 - end, 38 - actions = { 39 - Log:new{ 40 - message = function(ctx) 36 + end, 37 + actions = { 38 + log(function(ctx) 41 39 return string.format("Torrent Finished/Done: %s. Ratio: %.2f. Seeding Time: %sm", ctx.torrent.name, ctx.torrent.ratio, tostring(ctx.torrent.seeding_duration/60)) 42 - end 43 - }, 44 - TorrentRemove:new{ 45 - remove_files = true 40 + end), 41 + torrent.remove({ 42 + remove_files = true 43 + }) 46 44 } 47 - } 48 - } 45 + }) 46 + end