+ EpisodeFormat: don't use inferred file for crc32 binding
* fixed "All Episodes" link in TVDotComClient
This commit is contained in:
parent
a41f80bd9d
commit
8729d227a1
|
@ -125,23 +125,20 @@ public class EpisodeFormatBindingBean {
|
|||
|
||||
@Define("crc32")
|
||||
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
|
||||
String checksum = FileBotUtilities.getEmbeddedChecksum(inferredMediaFile.getName());
|
||||
String checksum = FileBotUtilities.getEmbeddedChecksum(mediaFile.getName());
|
||||
|
||||
if (checksum != null)
|
||||
return checksum;
|
||||
|
||||
// try to get checksum from sfv file
|
||||
checksum = getChecksumFromSfvFile(inferredMediaFile);
|
||||
checksum = getChecksumFromSfvFile(mediaFile);
|
||||
|
||||
if (checksum != null)
|
||||
return checksum;
|
||||
|
||||
// calculate checksum from file
|
||||
return crc32(inferredMediaFile);
|
||||
return crc32(mediaFile);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public class TVDotComClient implements EpisodeListProvider {
|
|||
|
||||
|
||||
@Override
|
||||
public List<Episode> getEpisodeList(SearchResult searchResult) throws Exception {
|
||||
public List<Episode> getEpisodeList(final SearchResult searchResult) throws Exception {
|
||||
|
||||
// get document for season 1
|
||||
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
|
||||
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
|
||||
|
@ -133,7 +142,6 @@ public class TVDotComClient implements EpisodeListProvider {
|
|||
|
||||
@Override
|
||||
public List<Episode> getEpisodeList(SearchResult searchResult, int season) throws IOException, SAXException {
|
||||
|
||||
Document dom = getHtmlDocument(getEpisodeListLink(searchResult, season).toURL());
|
||||
|
||||
return getEpisodeList(searchResult, dom);
|
||||
|
@ -180,34 +188,19 @@ public class TVDotComClient implements EpisodeListProvider {
|
|||
|
||||
@Override
|
||||
public URI getEpisodeListLink(SearchResult searchResult) {
|
||||
return getEpisodeListLink(searchResult, 0);
|
||||
return getEpisodeListLink(searchResult, "All");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URI getEpisodeListLink(SearchResult searchResult, int season) {
|
||||
URL episodeListingUrl = ((HyperLink) searchResult).getURL();
|
||||
|
||||
return URI.create(episodeListingUrl + "?season=" + season);
|
||||
return getEpisodeListLink(searchResult, Integer.toString(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 List<Episode> call() throws Exception {
|
||||
return getEpisodeList(searchResult, season);
|
||||
}
|
||||
public URI getEpisodeListLink(SearchResult searchResult, String season) {
|
||||
URL episodeGuide = ((HyperLink) searchResult).getURL();
|
||||
|
||||
return URI.create(episodeGuide + "?season=" + season);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ public class TVDotComClientTest {
|
|||
public void getEpisodeListEncoding() throws Exception {
|
||||
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("Exposé", episode.getTitle());
|
||||
|
|
Loading…
Reference in New Issue