After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 741607 - WIP: Use lua to parse video titles
WIP: Use lua to parse video titles
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: plugins
unspecified
Other All
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2014-12-16 16:59 UTC by Bastien Nocera
Modified: 2015-03-02 17:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
lua-factory: Add hack for running tests on lua sources (1.07 KB, patch)
2014-12-16 16:59 UTC, Bastien Nocera
none Details | Review
WIP: Use lua to parse video titles (4.98 KB, patch)
2014-12-16 16:59 UTC, Bastien Nocera
needs-work Details | Review
lua source: video-title-parsing (11.06 KB, patch)
2015-03-01 01:33 UTC, Victor Toso
none Details | Review
v2 (8.76 KB, patch)
2015-03-02 13:44 UTC, Victor Toso
accepted-commit_now Details | Review

Description Bastien Nocera 2014-12-16 16:59:46 UTC
Victor said he'd finish it :)
Comment 1 Bastien Nocera 2014-12-16 16:59:50 UTC
Created attachment 292850 [details] [review]
lua-factory: Add hack for running tests on lua sources

Same snippet of code as in the local-metadata plugin.
Comment 2 Bastien Nocera 2014-12-16 16:59:55 UTC
Created attachment 292851 [details] [review]
WIP: Use lua to parse video titles

Instead of regexes in local-metadata
Comment 3 Bastien Nocera 2015-02-17 17:22:10 UTC
Comment on attachment 292850 [details] [review]
lua-factory: Add hack for running tests on lua sources

bug 741784 had a similar patch.
Comment 4 Victor Toso 2015-03-01 01:33:59 UTC
Created attachment 298194 [details] [review]
lua source: video-title-parsing

Using the lua patterns to the job :-)
I think this is easier to read and fix when comparing to the regexp parser. 

One difference here is that, this source is parsing the title but maybe it should do for URIs too?

I changed the local-metadata to test both local-metadata and the lua source... but I'll include the tests properly after fixing #741784
Comment 5 Bastien Nocera 2015-03-02 10:33:34 UTC
Review of attachment 298194 [details] [review]:

No need to mention me. I would prefer a better explanation in the commit message though.

Does it pass the test suite now?

::: tests/local-metadata/test_local_metadata.c
@@ +116,3 @@
 
+  registry = grl_registry_get_default ();
+  source = grl_registry_lookup_source (registry, "grl-video-title-parsing");

Isn't the source name the only difference between the 2 test functions? If so, factor it out.
Comment 6 Victor Toso 2015-03-02 13:11:47 UTC
(In reply to Bastien Nocera from comment #5)
> Review of attachment 298194 [details] [review] [review]:
> 
> No need to mention me. I would prefer a better explanation in the commit
> message though.

Sure, something like below is fine?

"video-title-parsing: lua patterns instead of regex

This source is an alternative to local-metadata and it uses lua patterns in order to get metadata from the title of the file.

The test suite for video-title-parsing is the same for the local-metadata"

> 
> Does it pass the test suite now?

It does! (for titles, not URIs)

> 
> ::: tests/local-metadata/test_local_metadata.c
> @@ +116,3 @@
>  
> +  registry = grl_registry_get_default ();
> +  source = grl_registry_lookup_source (registry, "grl-video-title-parsing");
> 
> Isn't the source name the only difference between the 2 test functions? If
> so, factor it out.

I'm also checking if the array of test case has title before calling the resolve function. (sometimes it only has URIs)

I separated in two functions to have two different tests, not sure how to do it properly with one function and a global GrlSource.

Is it okay to leave this [lua source] test inside local-metadata tests?

Also, should this source handle URIs too?
Comment 7 Bastien Nocera 2015-03-02 13:29:34 UTC
(In reply to Victor Toso from comment #6)
> (In reply to Bastien Nocera from comment #5)
> > Review of attachment 298194 [details] [review] [review] [review]:
> > 
> > No need to mention me. I would prefer a better explanation in the commit
> > message though.
> 
> Sure, something like below is fine?
> 
> "video-title-parsing: lua patterns instead of regex

"lua-factory: Add title parsing Lua source"

> This source is an alternative to local-metadata and it uses lua patterns in
> order to get metadata from the title of the file.
> 
> The test suite for video-title-parsing is the same for the local-metadata"
> 
> > 
> > Does it pass the test suite now?
> 
> It does! (for titles, not URIs)
> 
> > 
> > ::: tests/local-metadata/test_local_metadata.c
> > @@ +116,3 @@
> >  
> > +  registry = grl_registry_get_default ();
> > +  source = grl_registry_lookup_source (registry, "grl-video-title-parsing");
> > 
> > Isn't the source name the only difference between the 2 test functions? If
> > so, factor it out.
> 
> I'm also checking if the array of test case has title before calling the
> resolve function. (sometimes it only has URIs)
> 
> I separated in two functions to have two different tests, not sure how to do
> it properly with one function and a global GrlSource.
> 
> Is it okay to leave this [lua source] test inside local-metadata tests?
> 
> Also, should this source handle URIs too?

void
my_real_test(const char *source_name,
             gboolean check_for_uris)
{
   ...
}

And call this from the 2 different tests?
Comment 8 Victor Toso 2015-03-02 13:44:48 UTC
Created attachment 298293 [details] [review]
v2
Comment 9 Victor Toso 2015-03-02 13:45:44 UTC
> > "video-title-parsing: lua patterns instead of regex
> 
> "lua-factory: Add title parsing Lua source"

Fixed.

> 
> > This source is an alternative to local-metadata and it uses lua patterns in
> > order to get metadata from the title of the file.
> > 
> > The test suite for video-title-parsing is the same for the local-metadata"
> > 
> > > 
> > > Does it pass the test suite now?
> > 
> > It does! (for titles, not URIs)
> > 
> > > 
> > > ::: tests/local-metadata/test_local_metadata.c
> > > @@ +116,3 @@
> > >  
> > > +  registry = grl_registry_get_default ();
> > > +  source = grl_registry_lookup_source (registry, "grl-video-title-parsing");
> > > 
> > > Isn't the source name the only difference between the 2 test functions? If
> > > so, factor it out.
> > 
> > I'm also checking if the array of test case has title before calling the
> > resolve function. (sometimes it only has URIs)
> > 
> > I separated in two functions to have two different tests, not sure how to do
> > it properly with one function and a global GrlSource.
> > 
> > Is it okay to leave this [lua source] test inside local-metadata tests?
> > 
> > Also, should this source handle URIs too?
> 
> void
> my_real_test(const char *source_name,
>              gboolean check_for_uris)
> {
>    ...
> }
> 
> And call this from the 2 different tests?

Thanks
Comment 10 Bastien Nocera 2015-03-02 14:22:47 UTC
Review of attachment 298293 [details] [review]:

Looks good!

We should add support for URIs as well. We will probably need to add a helper in lua-factory to handle that though, to be sure that the behaviour is the same as the Filesystem or Tracker plugins.
Comment 11 Victor Toso 2015-03-02 17:24:57 UTC
pushed as ba849446abcc512a7cff07b3e975d409139bc898
(not very lucky with git-bz lately)

(In reply to Bastien Nocera from comment #10)
> Review of attachment 298293 [details] [review] [review]:
> 
> Looks good!
> 
> We should add support for URIs as well. We will probably need to add a
> helper in lua-factory to handle that though, to be sure that the behaviour
> is the same as the Filesystem or Tracker plugins.

Indeed, I'll try to do it this week.