1
0
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:
2012-01-16 13:28:59 -02:00
parent 1719e54b77
commit e943b08ede
17 changed files with 33 additions and 44 deletions

View File

@@ -16,7 +16,6 @@
*/ */
package com.rogiel.httpchannel.service; package com.rogiel.httpchannel.service;
import java.io.Closeable;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
@@ -32,7 +31,7 @@ import java.nio.channels.ReadableByteChannel;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @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 * @return the file size
*/ */

View File

@@ -16,7 +16,6 @@
*/ */
package com.rogiel.httpchannel.service; package com.rogiel.httpchannel.service;
import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.channels.Channel; 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> * @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 * @return the file size
*/ */

View File

@@ -7,7 +7,7 @@
<version>1.0.0</version> <version>1.0.0</version>
<relativePath>..</relativePath> <relativePath>..</relativePath>
</parent> </parent>
<artifactId>httpchannel-capcha</artifactId> <artifactId>httpchannel-captcha</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>HttpChannel/CaptchaService</name> <name>HttpChannel/CaptchaService</name>

View File

@@ -220,8 +220,7 @@ public class HotFileService extends AbstractHttpService implements Service,
protected class DownloaderImpl extends protected class DownloaderImpl extends
AbstractHttpDownloader<NullDownloaderConfiguration> { AbstractHttpDownloader<NullDownloaderConfiguration> {
public DownloaderImpl(URL url, public DownloaderImpl(URL url, NullDownloaderConfiguration configuration) {
NullDownloaderConfiguration configuration) {
super(url, configuration); super(url, configuration);
} }

View File

@@ -276,7 +276,7 @@ public class UploadHereService extends AbstractHttpService implements Service,
@Override @Override
public void logout() throws IOException { public void logout() throws IOException {
post("http://www.uploadking.com/login").parameter("do", "logout") post("http://www.uploadhere.com/login").parameter("do", "logout")
.request(); .request();
// TODO check logout status // TODO check logout status
} }

View File

@@ -40,7 +40,7 @@ import com.rogiel.httpchannel.util.PatternUtils;
import com.rogiel.httpchannel.util.htmlparser.HTMLPage; 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> * @author <a href="http://www.rogiel.com/">Rogiel</a>
* @since 1.0 * @since 1.0
@@ -103,7 +103,7 @@ public class UploadKingService extends AbstractHttpService implements Service,
@Override @Override
public long getMaximumFilesize() { public long getMaximumFilesize() {
return 1 * 1024 * 1024 * 1024; return 500 * 1024 * 1024;
} }
@Override @Override
@@ -191,7 +191,7 @@ public class UploadKingService extends AbstractHttpService implements Service,
final String uploadID = page.getInputValue("UPLOAD_IDENTIFIER"); final String uploadID = page.getInputValue("UPLOAD_IDENTIFIER");
final LinkedUploadChannel channel = createLinkedChannel(this); final LinkedUploadChannel channel = createLinkedChannel(this);
uploadFuture = multipartPost(url).parameter("file_0", channel) uploadFuture = multipartPost(url).parameter("file", channel)
.parameter("u", userCookie) .parameter("u", userCookie)
.parameter("UPLOAD_IDENTIFIER", uploadID).asStringAsync(); .parameter("UPLOAD_IDENTIFIER", uploadID).asStringAsync();
return waitChannelLink(channel, uploadFuture); return waitChannelLink(channel, uploadFuture);

View File

@@ -17,6 +17,9 @@
<module>httpchannel-service-megaupload</module> <module>httpchannel-service-megaupload</module>
<module>httpchannel-service-hotfile</module> <module>httpchannel-service-hotfile</module>
<module>httpchannel-service-multiupload</module> <module>httpchannel-service-multiupload</module>
<module>httpchannel-service-zshare</module>
<module>httpchannel-service-filesonic</module>
</modules> </modules>
<dependencies> <dependencies>

View File

@@ -19,6 +19,7 @@ package com.rogiel.httpchannel.service.channel;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
import com.rogiel.httpchannel.service.UploadChannel; import com.rogiel.httpchannel.service.UploadChannel;
@@ -49,7 +50,14 @@ public class LinkedUploadChannel implements UploadChannel {
public int write(ByteBuffer src) throws IOException { public int write(ByteBuffer src) throws IOException {
if (channel == null) if (channel == null)
throw new IOException("Channel is not linked yet"); throw new IOException("Channel is not linked yet");
if(!open)
throw new ClosedChannelException();
try {
return channel.write(src); return channel.write(src);
} catch(IOException e) {
close();
throw e;
}
} }
@Override @Override
@@ -85,7 +93,7 @@ public class LinkedUploadChannel implements UploadChannel {
return downloadLink; return downloadLink;
} }
public void linkChannel(WritableByteChannel channel) throws IOException { protected void linkChannel(WritableByteChannel channel) throws IOException {
if (this.channel != null) if (this.channel != null)
throw new IOException("This channel is already linked."); throw new IOException("This channel is already linked.");
this.channel = channel; this.channel = channel;

View File

@@ -49,10 +49,9 @@ public class LinkedUploadChannelContentBody extends AbstractContentBody {
public void writeTo(OutputStream out) throws IOException { public void writeTo(OutputStream out) throws IOException {
final WritableByteChannel outputChannel = Channels.newChannel(out); final WritableByteChannel outputChannel = Channels.newChannel(out);
channel.linkChannel(outputChannel); channel.linkChannel(outputChannel);
while (channel.isOpen() && outputChannel.isOpen()) { while (channel.isOpen() && outputChannel.isOpen()) {
try { try {
Thread.sleep(500); Thread.sleep(50);
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
} }

29
pom.xml
View File

@@ -15,8 +15,7 @@
<module>httpchannel-service</module> <module>httpchannel-service</module>
<module>httpchannel-util</module> <module>httpchannel-util</module>
<module>httpchannel-channelcopy</module> <module>httpchannel-channelcopy</module>
<module>httpchannel-captcha</module>
<module>httpchannel-capcha</module>
</modules> </modules>
<build> <build>
@@ -37,36 +36,12 @@
<target>1.7</target> <target>1.7</target>
</configuration> </configuration>
</plugin> </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> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<configuration> <configuration>
<descriptors> <descriptors>
<descriptor>assembly/distribution-bin.xml</descriptor> <descriptor>src/main/assembly/distribution-bin.xml</descriptor>
</descriptors> </descriptors>
</configuration> </configuration>
<executions> <executions>

View File

@@ -9,12 +9,19 @@
<baseDirectory></baseDirectory> <baseDirectory></baseDirectory>
<moduleSets> <moduleSets>
<moduleSet> <moduleSet>
<includeSubModules>false</includeSubModules> <includeSubModules>true</includeSubModules>
<binaries> <binaries>
<unpack>true</unpack>
<useStrictFiltering>true</useStrictFiltering>
<unpackOptions>
<includes>
<include>com/rogiel/httpchannel/**</include>
</includes>
</unpackOptions>
<includeDependencies>false</includeDependencies> <includeDependencies>false</includeDependencies>
<includes> <includes>
<include>httpchannel-service</include>
<include>httpchannel-api</include> <include>httpchannel-api</include>
<include>httpchannel-service</include>
</includes> </includes>
</binaries> </binaries>
</moduleSet> </moduleSet>