Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alperensert committed Dec 19, 2021
0 parents commit 048fc72
Show file tree
Hide file tree
Showing 21 changed files with 1,843 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: OSSRH Release 📦

on:
release:
types: [published]

jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Maven Central Repository
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Install GPG secret key
run: echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import

- name: Publish to Maven Central
run: |
mvn \
--no-transfer-progress \
--batch-mode \
-Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} \
-DskipTests \
-Prelease \
deploy
env:
MAVEN_USERNAME: ${{ secrets.REPO_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.REPO_PASSWORD }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea/
/target/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
157 changes: 157 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.github.alperensert</groupId>
<artifactId>capmonster_java</artifactId>
<version>1.3</version>

<name>capmonster_java</name>
<description>Capmonster.cloud package for Java</description>
<url>https://github.com/alperensert/capmonster_java</url>

<licenses>
<license>
<name>MIT License</name>
<url>https://github.com/alperensert/capmonster_java/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>

<developers>
<developer>
<name>Alperen Sert</name>
<email>mail@alperenn.com</email>
<url>https://github.com/alperensert</url>
</developer>
</developers>

<scm>
<url>https://github.com/alperensert/capmonster_java.git</url>
<connection>scm:git:git://github.com/alperensert/capmonster_java.git</connection>
<developerConnection>scm:git:git@github.com:alperensert/capmonster_java.git</developerConnection>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<name>Central Repository OSSRH</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20211205</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>release</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.github.alperensert.capmonster_java.exceptions;

public class CapmonsterException extends RuntimeException {
public String CODE;
public String DESCRIPTION;
public CapmonsterException(String code, String description) {
super("[" + code + "] " + description);
this.DESCRIPTION = description;
this.CODE = code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package io.github.alperensert.capmonster_java.tasks;

import io.github.alperensert.capmonster_java.utilities.*;
import org.json.JSONObject;

/**
* This class contains everything for FunCaptcha solving task
* @see Client
* @since 1.1
*/
public class FunCaptchaTask extends Client {
/**
* @param apiKey Your unique key for solving captchas
*/
public FunCaptchaTask(String apiKey) {
super(apiKey);
}

/**
* Create Funcaptcha task easily with task builder
* @param taskBuilder TaskBuilder
* @return Created task's ID
*/
public int createTask(TaskBuilder taskBuilder) {
RequestBuilder request = new RequestBuilder(this.CLIENT_KEY, "FunCaptchaTask")
.addTask("websiteURL", taskBuilder.websiteUrl)
.addTask("websitePublicKey", taskBuilder.websitePublicKey)
.addTask("funcaptchaApiJSSubdomain", taskBuilder.apiJSSubdomain)
.addUserAgent(taskBuilder.userAgent)
.addProxy(taskBuilder.proxy)
.addCookies(taskBuilder.cookies);
JSONObject t = makeRequest("createTask", request.build());
return t.getInt("taskId");
}

public static class TaskBuilder {
/**
* Address of a webpage with FunCaptcha
*/
private final String websiteUrl;
/**
* FunCaptcha website key. Mostly you can find in funcaptcha div
* <pre>{@code
* <div id="funcaptcha" data-pkey="THAT_ONE"></div>
* }</pre>
*/
private final String websitePublicKey;
/**
* A special subdomain of funcaptcha.com, from which the JS captcha widget should be loaded.
* Most FunCaptcha installations work from shared domains, so this option is only needed in certain rare cases.
*/
private String apiJSSubdomain;
/**
* @see Proxy
*/
private Proxy proxy;
/**
* @see UserAgent
*/
private UserAgent userAgent;
/**
* @see Cookies
*/
private Cookies cookies;

/**
* @param websiteUrl Website URL
* @param websitePublicKey Website public key
* @see #websiteUrl
* @see #websitePublicKey
* @since 1.2
*/
public TaskBuilder(String websiteUrl, String websitePublicKey) {
this.websiteUrl = websiteUrl;
this.websitePublicKey = websitePublicKey;
}

/**
* @param subdomain API javascript subdomain
* @see #apiJSSubdomain
* @return TaskBuilder
*/
public TaskBuilder setApiSubdomain(String subdomain) {
this.apiJSSubdomain = subdomain;
return this;
}

/**
* Additional cookies which we must use during interaction with target page or Google.
* @param cookies Cookies
* @see Cookies
* @return TaskBuilder
* @since 1.2
*/
public TaskBuilder setCookies(Cookies cookies) {
this.cookies = cookies;
return this;
}

/**
* Set proxy for the task.
* If the proxy is authorized by IP, then be sure to add 116.203.55.208 to the white list.
* @param proxy Proxy
* @see Proxy
* @return TaskBuilder
* @since 1.2
*/
public TaskBuilder setProxy(Proxy proxy) {
if (proxy != null) this.proxy = proxy;
return this;
}

/**
* Browser's User-Agent which is used in emulation. It is required that you use a signature of a modern browser,
* otherwise Google will ask you to "update your browser"
* @param ua UserAgent
* @see UserAgent
* @return TaskBuilder
* @since 1.2
*/
public TaskBuilder setUserAgent(UserAgent ua) {
this.userAgent = ua;
return this;
}
}
}
Loading

0 comments on commit 048fc72

Please sign in to comment.