[grilo-plugins] local-metadata: Support seasonxepisode format in filenames



commit 9bb477ecf935c41aa54a61052c4ac85ff778d668
Author: Elad Alfassa <elad fedoraproject org>
Date:   Thu Feb 27 00:33:09 2014 +0200

    local-metadata: Support seasonxepisode format in filenames
    
    seasonxepisode, for example 5x24 is a less common format than S5E24, but it's
    out there.
    
    This commit adds support for this format in filenames.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725026

 src/local-metadata/grl-local-metadata.c    |    8 ++++++--
 tests/local-metadata/test_local_metadata.c |    1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/local-metadata/grl-local-metadata.c b/src/local-metadata/grl-local-metadata.c
index 7502683..bd12a84 100644
--- a/src/local-metadata/grl-local-metadata.c
+++ b/src/local-metadata/grl-local-metadata.c
@@ -48,7 +48,7 @@ GRL_LOG_DOMAIN_STATIC(local_metadata_log_domain);
 #define TV_REGEX                                \
   "(?<showname>.*)\\."                          \
   "(?<season>(?:\\d{1,2})|(?:[sS]\\K\\d{1,2}))" \
-  "(?<episode>(?:\\d{2})|(?:[eE]\\K\\d{1,2}))"  \
+  "(?<episode>(?:\\d{2})|(?:[eEx]\\K\\d{1,2}))"  \
   "\\.?(?<name>.*)?"
 #define MOVIE_REGEX                             \
   "(?<name>.*)"                                 \
@@ -241,6 +241,7 @@ video_sanitise_string (const gchar *str)
 {
   int    i;
   gchar *line;
+  GRegex *regex;
 
   line = (gchar *) str;
   for (i = 0; video_blacklisted_prefix[i]; i++) {
@@ -259,6 +260,9 @@ video_sanitise_string (const gchar *str)
       return g_strndup (line, end - line);
     }
   }
+  regex = g_regex_new ("\\.-\\.", 0, 0, NULL);
+  line = g_regex_replace_literal(regex, line, -1, 0, ".", 0, NULL);
+  g_regex_unref(regex);
 
   return g_strdup (line);
 }
@@ -369,7 +373,7 @@ video_guess_values_from_display_name (const gchar *display_name,
     if (episode) {
       gchar *e = g_match_info_fetch_named (info, "episode");
       if (e) {
-        if (*e == 'e' || *e == 'E') {
+        if (*e == 'e' || *e == 'E' || *e == 'x') {
           *episode = atoi (e + 1);
         } else {
           *episode = atoi (e);
diff --git a/tests/local-metadata/test_local_metadata.c b/tests/local-metadata/test_local_metadata.c
index f2f8afb..81aa2fd 100644
--- a/tests/local-metadata/test_local_metadata.c
+++ b/tests/local-metadata/test_local_metadata.c
@@ -94,6 +94,7 @@ test_episodes (void)
     { "metalocalypse.s02e01.dvdrip.xvid-ffndvd.avi", NULL, "metalocalypse", 2, 1 },
     { "Boardwalk.Empire.S04E01.HDTV.x264-2HD.mp4", NULL, "Boardwalk Empire", 4, 1 },
     { NULL, "file:///home/test/My%20super%20series.S01E01.mp4", "My super series", 1, 1 },
+    { "Adventure Time - 2x01 - It Came from the Nightosphere.mp4", NULL, "Adventure Time", 2, 1 }
   };
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]