* fix Sublight by spoofing Sublight;3.6.0 auth credentials
This commit is contained in:
parent
f8b0eaea95
commit
32e40255c8
|
@ -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=
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<SearchResult> search(String query) throws WebServiceException {
|
||||
// require login
|
||||
|
@ -106,7 +106,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit
|
|||
return results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<SubtitleDescriptor> 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<File, List<SubtitleDescriptor>> getSubtitleList(File[] files, final String languageName) throws Exception {
|
||||
Map<File, List<SubtitleDescriptor>> subtitles = new HashMap<File, List<SubtitleDescriptor>>(files.length);
|
||||
|
||||
|
@ -173,7 +173,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<SubtitleDescriptor> getSubtitleList(String videoHash, String languageName) throws WebServiceException {
|
||||
List<SubtitleDescriptor> subtitles = new ArrayList<SubtitleDescriptor>();
|
||||
|
||||
|
@ -188,7 +188,7 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit
|
|||
return subtitles;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<Subtitle> 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<String, SubtitleLanguage> getLanguageAliasMap() {
|
||||
Map<String, SubtitleLanguage> languages = new HashMap<String, SubtitleLanguage>(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<String, SubtitleLanguage> 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<String> error = new Holder<String>();
|
||||
|
@ -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
|
||||
|
|
|
@ -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<SubtitleDescriptor> list = client.getSubtitleList(new Movie("Terminator 2", 1991, 103064), null);
|
||||
List<SubtitleDescriptor> 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());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue