* added tvseries index

This commit is contained in:
Reinhard Pointner 2012-02-11 14:03:54 +00:00
parent f3626ec81d
commit b314725186
3 changed files with 32 additions and 1 deletions

View File

@ -24,6 +24,7 @@ import java.util.zip.GZIPInputStream;
import net.sourceforge.filebot.web.CachedResource;
import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.TheTVDBClient.TheTVDBSearchResult;
import net.sourceforge.tuned.ByteBufferInputStream;
@ -174,6 +175,11 @@ public class ReleaseInfo {
}
public synchronized TheTVDBSearchResult[] getSeriesList() throws IOException {
return seriesListResource.get();
}
public FileFilter getDiskFolderFilter() {
return new FolderEntryFilter(compile(getBundle(getClass().getName()).getString("pattern.diskfolder.entry")));
}
@ -183,6 +189,7 @@ public class ReleaseInfo {
protected final CachedResource<String[]> releaseGroupResource = new PatternResource(getBundle(getClass().getName()).getString("url.release-groups"));
protected final CachedResource<String[]> queryBlacklistResource = new PatternResource(getBundle(getClass().getName()).getString("url.query-blacklist"));
protected final CachedResource<Movie[]> movieListResource = new MovieResource(getBundle(getClass().getName()).getString("url.movie-list"));
protected final CachedResource<TheTVDBSearchResult[]> seriesListResource = new SeriesResource(getBundle(getClass().getName()).getString("url.series-list"));
protected static class PatternResource extends CachedResource<String[]> {
@ -223,6 +230,29 @@ public class ReleaseInfo {
}
protected static class SeriesResource extends CachedResource<TheTVDBSearchResult[]> {
public SeriesResource(String resource) {
super(resource, TheTVDBSearchResult[].class, 24 * 60 * 60 * 1000); // 24h update interval
}
@Override
public TheTVDBSearchResult[] process(ByteBuffer data) throws IOException {
Scanner scanner = new Scanner(new GZIPInputStream(new ByteBufferInputStream(data)), "UTF-8").useDelimiter("\t|\n");
List<TheTVDBSearchResult> tvshows = new ArrayList<TheTVDBSearchResult>();
while (scanner.hasNext()) {
int sid = scanner.nextInt();
String name = scanner.next();
tvshows.add(new TheTVDBSearchResult(name, sid));
}
return tvshows.toArray(new TheTVDBSearchResult[0]);
}
}
protected static class FolderEntryFilter implements FileFilter {
private final Pattern entryPattern;

View File

@ -12,6 +12,7 @@ url.query-blacklist: http://filebot.sourceforge.net/data/query-blacklist.txt
# list of all movies (id, name, year)
url.movie-list: http://filebot.sourceforge.net/data/movies.txt.gz
url.series-list: http://filebot.sourceforge.net/data/tvshows.txt.gz
# disk folder matcher
pattern.diskfolder.entry: ^BDMV$|^HVDVD_TS$|^VIDEO_TS$|^AUDIO_TS$|^VCD$

View File

@ -167,7 +167,7 @@ public class AnidbClient extends AbstractEpisodeListProvider {
}
protected synchronized List<AnidbSearchResult> getAnimeTitles() throws Exception {
public synchronized List<AnidbSearchResult> getAnimeTitles() throws Exception {
URL url = new URL("http", host, "/api/animetitles.dat.gz");
ResultCache cache = getCache();