diff options
author | Damian Minkov <damencho@jitsi.org> | 2014-05-09 12:40:16 +0300 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2014-05-09 12:44:05 +0300 |
commit | f14f2e248a73011901d7fb439975f80b1f826cdf (patch) | |
tree | 7c0ab8b50584f5df9796aec675d49a33ef13302d /src/net/java/sip/communicator/impl/replacement/vbox7 | |
parent | b2d44ec255747e377283e97188aa102539d2b3d6 (diff) | |
download | jitsi-f14f2e248a73011901d7fb439975f80b1f826cdf.zip jitsi-f14f2e248a73011901d7fb439975f80b1f826cdf.tar.gz jitsi-f14f2e248a73011901d7fb439975f80b1f826cdf.tar.bz2 |
Do replacements only inside plaintext nodes or on link content, avoid replacing text in already replaced one. Fixes some replacement services.
Diffstat (limited to 'src/net/java/sip/communicator/impl/replacement/vbox7')
-rw-r--r-- | src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java | 34 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf | 1 |
2 files changed, 32 insertions, 3 deletions
diff --git a/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java b/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java index 2d4b272..4c708ad 100644 --- a/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java +++ b/src/net/java/sip/communicator/impl/replacement/vbox7/ReplacementServiceVbox7Impl.java @@ -5,8 +5,10 @@ */ package net.java.sip.communicator.impl.replacement.vbox7; +import java.util.*; import java.util.regex.*; +import net.java.sip.communicator.service.httputil.*; import net.java.sip.communicator.service.replacement.*; import net.java.sip.communicator.util.*; @@ -29,8 +31,8 @@ public class ReplacementServiceVbox7Impl * The regex used to match the link in the message. */ public static final String VBOX7_PATTERN = - "(?<=>)(https?\\:\\/\\/(www\\.)*?vbox7\\.com" - + "\\/play\\:([a-zA-Z0-9_\\-]+))([?&]\\w+=[\\w-]*)*(?=</A>)"; + "(https?\\:\\/\\/(www\\.)*?vbox7\\.com" + + "\\/play\\:([a-zA-Z0-9_\\-]+))([?&]\\w+=[\\w-]*)*"; /** * Configuration label shown in the config form. @@ -63,10 +65,36 @@ public class ReplacementServiceVbox7Impl Pattern.CASE_INSENSITIVE | Pattern.DOTALL); Matcher m = p.matcher(sourceString); String thumbUrl = sourceString; + String id = null; while (m.find()) { - thumbUrl = "https://i.vbox7.com/p/" + m.group(1) + "3.jpg"; + id = m.group(1); + thumbUrl = "https://i.vbox7.com/p/" + id + "3.jpg"; + } + + if(id != null) + { + try + { + HttpUtils.HTTPResponseResult res = HttpUtils.openURLConnection( + "http://vbox7.com/etc/ext.do?key=" + id); + + StringTokenizer toks = new StringTokenizer( + res.getContentString(), "&"); + while(toks.hasMoreTokens()) + { + String value = toks.nextToken(); + String[] entries = value.split("="); + if(entries.length > 1 + && entries[0].equals("jpg_addr")) + { + return "http://" + entries[1]; + } + } + } + catch(Throwable t) + {} } return thumbUrl; diff --git a/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf b/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf index d7da965..1ebe3e6 100644 --- a/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf +++ b/src/net/java/sip/communicator/impl/replacement/vbox7/vbox7.source.manifest.mf @@ -5,6 +5,7 @@ Bundle-Vendor: jitsi.org Bundle-Version: 1.0.0 Bundle-SymbolicName: net.java.sip.communicator.replacement.vbox7 Import-Package: org.osgi.framework, + net.java.sip.communicator.service.httputil, net.java.sip.communicator.service.replacement, org.jitsi.service.configuration, org.jitsi.service.resources, net.java.sip.communicator.service.resources, |