1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-03-09 22:09:47 -04:00

+ EpisodeFormat: don't use inferred file for crc32 binding

* fixed "All Episodes" link in TVDotComClient
This commit is contained in:
Reinhard Pointner 2009-05-06 17:06:10 +00:00
parent a41f80bd9d
commit 8729d227a1
3 changed files with 21 additions and 31 deletions

View File

@ -125,23 +125,20 @@ public class EpisodeFormatBindingBean {
@Define("crc32") @Define("crc32")
public String getCRC32() throws IOException, InterruptedException { public String getCRC32() throws IOException, InterruptedException {
// use inferred media file (e.g. actual movie file instead of subtitle file)
File inferredMediaFile = getInferredMediaFile();
// try to get checksum from file name // try to get checksum from file name
String checksum = FileBotUtilities.getEmbeddedChecksum(inferredMediaFile.getName()); String checksum = FileBotUtilities.getEmbeddedChecksum(mediaFile.getName());
if (checksum != null) if (checksum != null)
return checksum; return checksum;
// try to get checksum from sfv file // try to get checksum from sfv file
checksum = getChecksumFromSfvFile(inferredMediaFile); checksum = getChecksumFromSfvFile(mediaFile);
if (checksum != null) if (checksum != null)
return checksum; return checksum;
// calculate checksum from file // calculate checksum from file
return crc32(inferredMediaFile); return crc32(mediaFile);
} }

View File

@ -85,7 +85,7 @@ public class TVDotComClient implements EpisodeListProvider {
@Override @Override
public List<Episode> getEpisodeList(SearchResult searchResult) throws Exception { public List<Episode> getEpisodeList(final SearchResult searchResult) throws Exception {
// get document for season 1 // get document for season 1
Document dom = getHtmlDocument(getEpisodeListLink(searchResult, 1).toURL()); Document dom = getHtmlDocument(getEpisodeListLink(searchResult, 1).toURL());
@ -110,7 +110,16 @@ public class TVDotComClient implements EpisodeListProvider {
// we already have the document for season 1, start with season 2 // we already have the document for season 1, start with season 2
for (int i = 2; i <= seasonCount; i++) { for (int i = 2; i <= seasonCount; i++) {
futures.add(executor.submit(new GetEpisodeList(searchResult, i))); // season used in anonymous class
final int season = i;
futures.add(executor.submit(new Callable<List<Episode>>() {
@Override
public List<Episode> call() throws Exception {
return getEpisodeList(searchResult, season);
}
}));
} }
// shutdown after all tasks are done // shutdown after all tasks are done
@ -133,7 +142,6 @@ public class TVDotComClient implements EpisodeListProvider {
@Override @Override
public List<Episode> getEpisodeList(SearchResult searchResult, int season) throws IOException, SAXException { public List<Episode> getEpisodeList(SearchResult searchResult, int season) throws IOException, SAXException {
Document dom = getHtmlDocument(getEpisodeListLink(searchResult, season).toURL()); Document dom = getHtmlDocument(getEpisodeListLink(searchResult, season).toURL());
return getEpisodeList(searchResult, dom); return getEpisodeList(searchResult, dom);
@ -180,34 +188,19 @@ public class TVDotComClient implements EpisodeListProvider {
@Override @Override
public URI getEpisodeListLink(SearchResult searchResult) { public URI getEpisodeListLink(SearchResult searchResult) {
return getEpisodeListLink(searchResult, 0); return getEpisodeListLink(searchResult, "All");
} }
@Override @Override
public URI getEpisodeListLink(SearchResult searchResult, int season) { public URI getEpisodeListLink(SearchResult searchResult, int season) {
URL episodeListingUrl = ((HyperLink) searchResult).getURL(); return getEpisodeListLink(searchResult, Integer.toString(season));
return URI.create(episodeListingUrl + "?season=" + season);
} }
private class GetEpisodeList implements Callable<List<Episode>> {
private final SearchResult searchResult;
private final int season;
public GetEpisodeList(SearchResult searchResult, int season) {
this.searchResult = searchResult;
this.season = season;
}
@Override public URI getEpisodeListLink(SearchResult searchResult, String season) {
public List<Episode> call() throws Exception { URL episodeGuide = ((HyperLink) searchResult).getURL();
return getEpisodeList(searchResult, season);
} return URI.create(episodeGuide + "?season=" + season);
} }
} }

View File

@ -100,7 +100,7 @@ public class TVDotComClientTest {
public void getEpisodeListEncoding() throws Exception { public void getEpisodeListEncoding() throws Exception {
List<Episode> list = tvdotcom.getEpisodeList(tvdotcom.search("Lost").get(0), 3); List<Episode> list = tvdotcom.getEpisodeList(tvdotcom.search("Lost").get(0), 3);
Episode episode = list.get(13); Episode episode = list.get(16);
assertEquals("Lost", episode.getSeriesName()); assertEquals("Lost", episode.getSeriesName());
assertEquals("Exposé", episode.getTitle()); assertEquals("Exposé", episode.getTitle());