From 32e40255c8b743bcf1aa53568723f397f0a4dddf Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 30 Jun 2012 08:43:51 +0000 Subject: [PATCH] * fix Sublight by spoofing Sublight;3.6.0 auth credentials --- .../sourceforge/filebot/Settings.properties | 4 +- .../net/sourceforge/filebot/WebServices.java | 2 +- .../filebot/web/SublightSubtitleClient.java | 42 +++++++++---------- .../web/SublightSubtitleClientTest.java | 11 ++--- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/source/net/sourceforge/filebot/Settings.properties b/source/net/sourceforge/filebot/Settings.properties index 5222de17..9b396b38 100644 --- a/source/net/sourceforge/filebot/Settings.properties +++ b/source/net/sourceforge/filebot/Settings.properties @@ -12,5 +12,7 @@ analytics.WebPropertyID: UA-25379256-3 # database api keys thetvdb.apikey: 58B4AA94C59AD656 themoviedb.apikey: 5a6edae568130bf10617b6d45be99f13 -sublight.apikey: afa9ecb2-a3ee-42b1-9225-000b4038bc85 serienjunkies.apikey: 9fbhw9uebfiwvbefzuwv + +sublight.clientid: Sublight;3.6.0 +sublight.apikey: YYa4Yajnqm5kXCEaetZeybYlfMIuGiJyTqqn0gfQv+mzC1KYEZq7jThuAFRehbti6d50PTqpBIy5wtfTyrMTb0IHWrGxDQHnHzcrtA8CO+337RhjZgw3OZsvJ/bJmd7ZAJbYMDoG/JXGYqpDFg38MteayjAZtQpNECUwZsbiuis= diff --git a/source/net/sourceforge/filebot/WebServices.java b/source/net/sourceforge/filebot/WebServices.java index aebcd80f..f41849a6 100644 --- a/source/net/sourceforge/filebot/WebServices.java +++ b/source/net/sourceforge/filebot/WebServices.java @@ -32,7 +32,7 @@ public final class WebServices { // subtitle dbs public static final OpenSubtitlesClient OpenSubtitles = new OpenSubtitlesClient(String.format("%s %s", getApplicationName(), getApplicationVersion())); - public static final SublightSubtitleClient Sublight = new SublightSubtitleClient(getApplicationName(), getApplicationProperty("sublight.apikey")); + public static final SublightSubtitleClient Sublight = new SublightSubtitleClient(getApplicationProperty("sublight.clientid"), getApplicationProperty("sublight.apikey")); public static final SubsceneSubtitleClient Subscene = new SubsceneSubtitleClient(); // movie dbs diff --git a/source/net/sourceforge/filebot/web/SublightSubtitleClient.java b/source/net/sourceforge/filebot/web/SublightSubtitleClient.java index fa26c551..b99f3c05 100644 --- a/source/net/sourceforge/filebot/web/SublightSubtitleClient.java +++ b/source/net/sourceforge/filebot/web/SublightSubtitleClient.java @@ -46,7 +46,7 @@ import net.sublight.webservice.SubtitleLanguage; public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtitleService { - private static final String iid = "42cc1701-3752-49e2-a148-332960073452"; + private static final String iid = "25f30171-518c-463b-a310-b9f8e1eddb40"; private final ClientInfo clientInfo = new ClientInfo(); @@ -54,31 +54,31 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit private String session; - + public SublightSubtitleClient(String clientIdentity, String apikey) { clientInfo.setClientId(clientIdentity); clientInfo.setApiKey(apikey); } - + @Override public String getName() { return "Sublight"; } - + @Override public URI getLink() { return URI.create("http://www.sublight.si"); } - + @Override public Icon getIcon() { return ResourceManager.getIcon("search.sublight"); } - + @Override public List search(String query) throws WebServiceException { // require login @@ -106,7 +106,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit return results; } - + @Override public List getSubtitleList(SearchResult searchResult, String languageName) throws WebServiceException { Movie movie = (Movie) searchResult; @@ -121,7 +121,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit return subtitles; } - + public Map> getSubtitleList(File[] files, final String languageName) throws Exception { Map> subtitles = new HashMap>(files.length); @@ -173,7 +173,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit } } - + public List getSubtitleList(String videoHash, String languageName) throws WebServiceException { List subtitles = new ArrayList(); @@ -188,7 +188,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit return subtitles; } - + public List getSubtitleList(String videoHash, String name, Integer year, String languageName) throws WebServiceException { // require login login(); @@ -245,14 +245,14 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit return subtitles.value.getSubtitle(); } - + @Override public boolean publishSubtitle(int imdbid, String languageName, File videoFile, File subtitleFile) throws Exception { //TODO implement upload feature return false; } - + public void publishSubtitle(int imdbid, String videoHash, String languageName, String releaseName, byte[] data) { // require login login(); @@ -279,7 +279,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit checkError(error); } - + protected Map getLanguageAliasMap() { Map languages = new HashMap(4); @@ -291,7 +291,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit return languages; } - + protected SubtitleLanguage getSubtitleLanguage(String languageName) { // check subtitle language enum for (SubtitleLanguage language : SubtitleLanguage.values()) { @@ -309,7 +309,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit throw new IllegalArgumentException("Illegal language: " + languageName); } - + protected String getLanguageName(SubtitleLanguage language) { // check alias list first for (Entry alias : getLanguageAliasMap().entrySet()) { @@ -321,7 +321,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit return language.value(); } - + protected synchronized byte[] getZipArchive(Subtitle subtitle) throws WebServiceException, InterruptedException { // require login login(); @@ -348,14 +348,14 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit return data.value; } - + @Override public URI getSubtitleListLink(SearchResult searchResult, String languageName) { // note that sublight can only be accessed via the soap API return URI.create("http://www.sublight.si/SearchSubtitles.aspx"); } - + protected synchronized void login() throws WebServiceException { if (webservice == null) { // lazy initialize because all the JAX-WS class loading can take quite some time @@ -383,7 +383,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit logoutTimer.set(10, TimeUnit.MINUTES, true); } - + protected synchronized void logout() throws WebServiceException { if (session != null) { Holder error = new Holder(); @@ -401,14 +401,14 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit } } - + protected void checkError(Holder error) throws WebServiceException { if (error.value != null) { throw new WebServiceException("Response indicates error: " + error.value); } } - + protected final Timer logoutTimer = new Timer() { @Override diff --git a/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java b/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java index 82e6f7bc..ca3974ab 100644 --- a/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java +++ b/test/net/sourceforge/filebot/web/SublightSubtitleClientTest.java @@ -19,7 +19,7 @@ import net.sublight.webservice.Subtitle; public class SublightSubtitleClientTest { - private static SublightSubtitleClient client = new SublightSubtitleClient(getApplicationName(), getApplicationProperty("sublight.apikey")); + private static SublightSubtitleClient client = new SublightSubtitleClient(getApplicationProperty("sublight.clientid"), getApplicationProperty("sublight.apikey")); @BeforeClass @@ -58,15 +58,12 @@ public class SublightSubtitleClientTest { @Test public void getSubtitleListAllLanguages() { - List list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), null); + List list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), "Croatian"); SubtitleDescriptor sample = list.get(0); - assertEquals("Terminator.2.1991.ULTIMATE.EDITION.DC.DVDXvID.AC3.CDx-HLS", sample.getName()); - assertEquals("Slovenian", sample.getLanguageName()); - - // check size - assertTrue(list.size() > 15); + assertEquals("Terminator.2-Judgment.Day[1991]DvDrip-aXXo", sample.getName()); + assertEquals("Croatian", sample.getLanguageName()); }