More general grepTheTvdbId()

This commit is contained in:
Reinhard Pointner 2017-01-25 05:22:07 +08:00
parent ca7a973cd3
commit a9cf202540
2 changed files with 3 additions and 1 deletions

View File

@ -1276,7 +1276,7 @@ public class MediaDetection {
public static List<Integer> grepTheTvdbId(CharSequence text) { public static List<Integer> grepTheTvdbId(CharSequence text) {
// scan for thetvdb id patterns like http://www.thetvdb.com/?tab=series&id=78874&lid=14 // scan for thetvdb id patterns like http://www.thetvdb.com/?tab=series&id=78874&lid=14
Pattern tvdbUrl = Pattern.compile("http[s]?://www.thetvdb.com/[?]tab=series&id=(\\d+)", Pattern.CASE_INSENSITIVE); Pattern tvdbUrl = Pattern.compile("\\w+://(?:\\w+[.])?thetvdb.com/[?]tab=\\w+&id=(\\d+)", Pattern.CASE_INSENSITIVE);
return streamMatches(text, tvdbUrl, m -> m.group(1)).map(Integer::new).collect(toList()); return streamMatches(text, tvdbUrl, m -> m.group(1)).map(Integer::new).collect(toList());
} }

View File

@ -34,6 +34,8 @@ public class MediaDetectionTest {
@Test @Test
public void grepTheTvdbId() throws Exception { public void grepTheTvdbId() throws Exception {
assertEquals("[78874]", MediaDetection.grepTheTvdbId("@see http://www.thetvdb.com/?tab=series&id=78874&lid=14").toString()); assertEquals("[78874]", MediaDetection.grepTheTvdbId("@see http://www.thetvdb.com/?tab=series&id=78874&lid=14").toString());
assertEquals("[78874]", MediaDetection.grepTheTvdbId("@see http://thetvdb.com/?tab=series&id=78874&lid=14").toString());
assertEquals("[78874]", MediaDetection.grepTheTvdbId("@see https://www.thetvdb.com/?tab=seasonall&id=78874&lid=14").toString());
} }
} }