mirror of
https://github.com/Rogiel/httpchannel
synced 2025-12-06 07:32:50 +00:00
Implements zshare.net and filesonic.com services
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.rogiel.httpchannel.service;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
|
||||
@@ -32,7 +31,7 @@ import java.nio.channels.ReadableByteChannel;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface DownloadChannel extends ReadableByteChannel, Closeable {
|
||||
public interface DownloadChannel extends HttpChannel, ReadableByteChannel {
|
||||
/**
|
||||
* @return the file size
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.rogiel.httpchannel.service;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channel;
|
||||
@@ -36,7 +35,7 @@ import com.rogiel.httpchannel.service.exception.UploadLinkNotFoundException;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface UploadChannel extends WritableByteChannel, Closeable {
|
||||
public interface UploadChannel extends HttpChannel, WritableByteChannel {
|
||||
/**
|
||||
* @return the file size
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<version>1.0.0</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>httpchannel-capcha</artifactId>
|
||||
<artifactId>httpchannel-captcha</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>HttpChannel/CaptchaService</name>
|
||||
@@ -220,8 +220,7 @@ public class HotFileService extends AbstractHttpService implements Service,
|
||||
|
||||
protected class DownloaderImpl extends
|
||||
AbstractHttpDownloader<NullDownloaderConfiguration> {
|
||||
public DownloaderImpl(URL url,
|
||||
NullDownloaderConfiguration configuration) {
|
||||
public DownloaderImpl(URL url, NullDownloaderConfiguration configuration) {
|
||||
super(url, configuration);
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ public class UploadHereService extends AbstractHttpService implements Service,
|
||||
|
||||
@Override
|
||||
public void logout() throws IOException {
|
||||
post("http://www.uploadking.com/login").parameter("do", "logout")
|
||||
post("http://www.uploadhere.com/login").parameter("do", "logout")
|
||||
.request();
|
||||
// TODO check logout status
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import com.rogiel.httpchannel.util.PatternUtils;
|
||||
import com.rogiel.httpchannel.util.htmlparser.HTMLPage;
|
||||
|
||||
/**
|
||||
* This service handles uploads to UploadKing.com.
|
||||
* This service handles uploads to zshare.net.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com/">Rogiel</a>
|
||||
* @since 1.0
|
||||
@@ -103,7 +103,7 @@ public class UploadKingService extends AbstractHttpService implements Service,
|
||||
|
||||
@Override
|
||||
public long getMaximumFilesize() {
|
||||
return 1 * 1024 * 1024 * 1024;
|
||||
return 500 * 1024 * 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,7 +191,7 @@ public class UploadKingService extends AbstractHttpService implements Service,
|
||||
final String uploadID = page.getInputValue("UPLOAD_IDENTIFIER");
|
||||
|
||||
final LinkedUploadChannel channel = createLinkedChannel(this);
|
||||
uploadFuture = multipartPost(url).parameter("file_0", channel)
|
||||
uploadFuture = multipartPost(url).parameter("file", channel)
|
||||
.parameter("u", userCookie)
|
||||
.parameter("UPLOAD_IDENTIFIER", uploadID).asStringAsync();
|
||||
return waitChannelLink(channel, uploadFuture);
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
<module>httpchannel-service-megaupload</module>
|
||||
<module>httpchannel-service-hotfile</module>
|
||||
<module>httpchannel-service-multiupload</module>
|
||||
<module>httpchannel-service-zshare</module>
|
||||
|
||||
<module>httpchannel-service-filesonic</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.rogiel.httpchannel.service.channel;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
|
||||
import com.rogiel.httpchannel.service.UploadChannel;
|
||||
@@ -49,7 +50,14 @@ public class LinkedUploadChannel implements UploadChannel {
|
||||
public int write(ByteBuffer src) throws IOException {
|
||||
if (channel == null)
|
||||
throw new IOException("Channel is not linked yet");
|
||||
return channel.write(src);
|
||||
if(!open)
|
||||
throw new ClosedChannelException();
|
||||
try {
|
||||
return channel.write(src);
|
||||
} catch(IOException e) {
|
||||
close();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +93,7 @@ public class LinkedUploadChannel implements UploadChannel {
|
||||
return downloadLink;
|
||||
}
|
||||
|
||||
public void linkChannel(WritableByteChannel channel) throws IOException {
|
||||
protected void linkChannel(WritableByteChannel channel) throws IOException {
|
||||
if (this.channel != null)
|
||||
throw new IOException("This channel is already linked.");
|
||||
this.channel = channel;
|
||||
|
||||
@@ -49,10 +49,9 @@ public class LinkedUploadChannelContentBody extends AbstractContentBody {
|
||||
public void writeTo(OutputStream out) throws IOException {
|
||||
final WritableByteChannel outputChannel = Channels.newChannel(out);
|
||||
channel.linkChannel(outputChannel);
|
||||
|
||||
while (channel.isOpen() && outputChannel.isOpen()) {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
29
pom.xml
29
pom.xml
@@ -15,8 +15,7 @@
|
||||
<module>httpchannel-service</module>
|
||||
<module>httpchannel-util</module>
|
||||
<module>httpchannel-channelcopy</module>
|
||||
|
||||
<module>httpchannel-capcha</module>
|
||||
<module>httpchannel-captcha</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
@@ -37,36 +36,12 @@
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>assembly/distribution-bin.xml</descriptor>
|
||||
<descriptor>src/main/assembly/distribution-bin.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
||||
@@ -9,12 +9,19 @@
|
||||
<baseDirectory></baseDirectory>
|
||||
<moduleSets>
|
||||
<moduleSet>
|
||||
<includeSubModules>false</includeSubModules>
|
||||
<includeSubModules>true</includeSubModules>
|
||||
<binaries>
|
||||
<unpack>true</unpack>
|
||||
<useStrictFiltering>true</useStrictFiltering>
|
||||
<unpackOptions>
|
||||
<includes>
|
||||
<include>com/rogiel/httpchannel/**</include>
|
||||
</includes>
|
||||
</unpackOptions>
|
||||
<includeDependencies>false</includeDependencies>
|
||||
<includes>
|
||||
<include>httpchannel-service</include>
|
||||
<include>httpchannel-api</include>
|
||||
<include>httpchannel-service</include>
|
||||
</includes>
|
||||
</binaries>
|
||||
</moduleSet>
|
||||
Reference in New Issue
Block a user