zammitjames / freenas-rss-extension

Automatically downloads and parses RSS feeds against a set of user defined filters.
3 stars 0 forks source link

"smart" does not work when episode format is like S01E01 (acts as already having) #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Setup a Feed and "smart" enabled Filter for shows which have episode
information in the format S01E01

What is the expected output? What do you see instead?
Expect it to match the Episode Numbers and download if not already
downloaded, instead it only downloads shows which use format 1x01 as the
episode format.

Please provide any additional information below.
RSS Debug log file reports the following:
[13 Nov 2009 22:17:09] Already have episode 

(i.e. fails to put the episode number on the end)

Original issue reported on code.google.com by omni...@gmail.com on 13 Nov 2009 at 12:45

GoogleCodeExporter commented 9 years ago
took a look at the source and made a change in the rss_cron.php to remove the 
blank
entries in the $matches, from:

$id = implode('x', array_slice($match, 3));

to:

$id = implode('x', array_slice(array_diff($match, array("")), 1));

which would appear to have resolved the issue for me

Original comment by omni...@gmail.com on 13 Nov 2009 at 1:30

GoogleCodeExporter commented 9 years ago
I think that should be
 $id = $id = implode('x', array_slice(array_diff($match, array("")), 0));

But otherwise, good catch ;)

Original comment by tre...@gmail.com on 13 Nov 2009 at 6:52

GoogleCodeExporter commented 9 years ago
Even better, we can get rid of the array_slice() and just implode() on the 
array_diff().  Might save a couple cycle and gives the proper results

Truncated Season/Episode Identifies:
  .S01E01.
  .01x02.
  .2008x11.01.

Become:
  array("01", "01", "", "", "")
  array("", "", "01", "02", "")
  array("", "", "2008", "11", "1")

Some fun PHP:
  echo implode('x', array_diff(array("01", "01", "", "", ""), array(""))), "\n";
  echo implode('x', array_diff(array("", "", "01", "02", ""), array(""))), "\n";
  echo implode('x', array_diff(array("", "", "2008", "11", "01"), array("")));

Outputs:
  01x01
  01x02
  2008x11x01

Original comment by tre...@gmail.com on 13 Nov 2009 at 7:46

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r68.

Original comment by tre...@gmail.com on 13 Nov 2009 at 9:02

GoogleCodeExporter commented 9 years ago
Thanks for looking at that so quick tresni.

I might be reading it wrong, but the only concern I have with it is that if I 
use two
feeds, one with epiode format 1x01, and the other S01E01... I would expect the
episode identifiers to be recorded as the same string so they don't both get 
downloaded.

Also the reason I used the split at 1 not 0 was becasue the $match[0] was 
listed as
"S01E01" and needed to avoid it for the above reason.

I think the issue can probably be solved nicely with a different regular 
expression,
but I am the first to admit its not my strong suit.

Original comment by omni...@gmail.com on 13 Nov 2009 at 9:47

GoogleCodeExporter commented 9 years ago
(referring to self) And that's what happens when you use Javascript to test 
your 
regular expression and php to actually do stuff.  completely forgot about match 
0.  
Good catch (then again I haven't actually tested this just, just proof of 
concept 
showed it would work :D )

Episide identifiers are currently converted to SSxEE[xYYYY] format. Numbers are 
not 
padded so 01x01 and S1E1 would return 2 different strings (01x01 & 1x1 
respectively).  
This logic needs a rewrite (or digit padding at a minimum.)

Will fix the initial bug shortly.  Smart Filtering cleanup is on the list of 
things 
to do.

Original comment by tre...@gmail.com on 13 Nov 2009 at 11:43

GoogleCodeExporter commented 9 years ago
Really fixed in r69.  Episode filtering needs to be rewritten.

Original comment by tre...@gmail.com on 14 Nov 2009 at 7:00

GoogleCodeExporter commented 9 years ago
You right, leading zero's will still be an isue; I've added a line to remove 
them and
will test it again over the new few weeks to see if the results are more like 
what I
am hoping for.

foreach ($match as &$value) $value = ltrim($value,'0');
$id = implode('x', array_slice(array_diff($match, array("")), 1));

Original comment by omni...@gmail.com on 15 Nov 2009 at 2:56

GoogleCodeExporter commented 9 years ago
It'd probably be easier/less cycles to update the regular expression to 
something like:
 /\W(?:S0*(\d+)E0*(\d+)|0*(\d+)x0*(\d+)(?:\.0*(\d+))?)\W/

That should still capture the relevant digits while discarding any leading 
zeros, saves 
from having to iterate the data again.

Original comment by tre...@gmail.com on 15 Nov 2009 at 3:09

GoogleCodeExporter commented 9 years ago
This works great! Was chasing my tail before trying work out why some were 
working
and others were not - last couple of days it's got everything 100%. Thanks so 
much.

Original comment by omni...@gmail.com on 17 Nov 2009 at 9:13

GoogleCodeExporter commented 9 years ago
Glad to hear it's working, I'll roll this up into a new release shortly.

Original comment by tre...@gmail.com on 19 Nov 2009 at 3:45