Skip to content

Commit

Permalink
Fixes for StreamResolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Mar 28, 2017
1 parent cbf76be commit d20c003
Show file tree
Hide file tree
Showing 22 changed files with 74 additions and 57 deletions.
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ dependencies {
compile "org.jetbrains.anko:anko-common:$anko_version"
compile "org.jetbrains.anko:anko-sqlite:$anko_version"

compile "net.xpece.android:support-preference:1.2.5"
compile "net.xpece.android:support-spinner:1.2.4"
compile "net.xpece.android:support-preference:1.2.7"
compile "net.xpece.android:support-spinner:1.2.7"

compile('com.mikepenz:aboutlibraries:5.9.3@aar') {
transitive = true
Expand Down Expand Up @@ -139,12 +139,12 @@ kapt {
}
}

static def getFromSecrets(String key) {
def Properties result = new Properties()
static getFromSecrets(String key) {
Properties result = new Properties()
def isCI = System.getenv('CI')

if (isCI != null && isCI.toBoolean()) {
return "dummy";
return "dummy"
}

try {
Expand All @@ -162,8 +162,8 @@ static def getFromSecrets(String key) {
return result[key]
}

static def shouldSign() {
def Properties result = new Properties()
static shouldSign() {
Properties result = new Properties()

try {
result.load(new FileInputStream(new File('secrets.properties')))
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/kotlin/com/proxerme/app/stream/StreamResolver.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.proxerme.app.stream

import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import okhttp3.HttpUrl
import okhttp3.Response
import java.io.IOException

Expand All @@ -14,7 +15,7 @@ abstract class StreamResolver {
abstract val name: String

open fun appliesTo(name: String) = name.contains(this.name, ignoreCase = true)
abstract fun resolve(url: String): StreamResolutionResult
abstract fun resolve(url: HttpUrl): StreamResolutionResult

@Throws(IOException::class)
protected fun validateAndGetResult(response: Response): String {
Expand All @@ -29,4 +30,4 @@ abstract class StreamResolver {
throw IOException()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.proxerme.app.stream.resolver

import android.net.Uri
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.extension.androidUri
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -13,7 +14,7 @@ class AkibaPassResolver : StreamResolver() {

override val name = "AkibaPass"

override fun resolve(url: String): StreamResolutionResult {
return StreamResolutionResult(Uri.parse(url), "text/html")
override fun resolve(url: HttpUrl): StreamResolutionResult {
return StreamResolutionResult(url.androidUri(), "text/html")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.proxerme.app.stream.resolver

import android.net.Uri
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.extension.androidUri
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -13,7 +14,7 @@ class AmazonPrimeVideoResolver : StreamResolver() {

override val name = "Amazon Prime Video"

override fun resolve(url: String): StreamResolutionResult {
return StreamResolutionResult(Uri.parse(url), "text/html")
override fun resolve(url: HttpUrl): StreamResolutionResult {
return StreamResolutionResult(url.androidUri(), "text/html")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.proxerme.app.stream.resolver

import android.net.Uri
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.extension.androidUri
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -13,7 +14,7 @@ class AnimeOnDemandResolver : StreamResolver() {

override val name = "Anime on demand"

override fun resolve(url: String): StreamResolutionResult {
return StreamResolutionResult(Uri.parse(url), "text/html")
override fun resolve(url: HttpUrl): StreamResolutionResult {
return StreamResolutionResult(url.androidUri(), "text/html")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.proxerme.app.dialog.AppRequiredDialog
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -18,11 +19,10 @@ class ClipfishResolver : StreamResolver() {

private val regex = Regex("video/(\\d+)?")

override fun resolve(url: String): StreamResolutionResult {
val id = regex.find(url)?.groupValues?.get(1) ?: throw StreamResolutionException()
override fun resolve(url: HttpUrl): StreamResolutionResult {
val id = regex.find(url.toString())?.groupValues?.get(1) ?: throw StreamResolutionException()

return StreamResolutionResult(Intent(Intent.ACTION_VIEW,
Uri.parse("clipfish://video/$id?ref=proxer")), {
return StreamResolutionResult(Intent(Intent.ACTION_VIEW, Uri.parse("clipfish://video/$id?ref=proxer")), {
AppRequiredDialog.show(it, "Clipfish", "com.rtli.clipfish")
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.proxerme.app.stream.resolver

import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -17,7 +18,7 @@ class CodeResolver : StreamResolver() {
return name.contains(this.name, false) || name.contains(alternativeName, false)
}

override fun resolve(url: String): StreamResolutionResult {
return StreamResolutionResult(url.replace(Regex("</?h1>"), ""))
override fun resolve(url: HttpUrl): StreamResolutionResult {
return StreamResolutionResult(url.toString().replace(Regex("</?h1>"), ""))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.proxerme.app.dialog.AppRequiredDialog
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -18,8 +19,8 @@ class CrunchyrollResolver : StreamResolver() {

private val regex = Regex("media_id=(\\d+)")

override fun resolve(url: String): StreamResolutionResult {
val id = regex.find(url)?.groupValues?.get(1) ?: throw StreamResolutionException()
override fun resolve(url: HttpUrl): StreamResolutionResult {
val id = regex.find(url.toString())?.groupValues?.get(1) ?: throw StreamResolutionException()

return StreamResolutionResult(Intent(Intent.ACTION_VIEW,
Uri.parse("crunchyroll://media/$id")), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.ProxerConnectionWrapper
import okhttp3.HttpUrl
import okhttp3.Request

/**
Expand All @@ -14,11 +15,11 @@ import okhttp3.Request
*/
class DailyMotionStreamResolver : StreamResolver() {

override val name = "Daily Motion"
override val name = "Dailymotion"

private val regex = Regex("\"qualities\":(\\{.+\\}\\]\\}),")

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
val response = validateAndGetResult(ProxerConnectionWrapper.httpClient
.newCall(Request.Builder()
.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.proxerme.app.stream.resolver
import android.net.Uri
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import okhttp3.HttpUrl

/**
* Resolver for the Daisuki hoster. Currently it only redirects to the homepage as the app does not
Expand All @@ -14,7 +15,7 @@ class DaisukiResolver : StreamResolver() {

override val name = "Daisuki"

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
return StreamResolutionResult(Uri.parse("http://daisuki.net"), "text/html")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.ProxerConnectionWrapper
import okhttp3.HttpUrl
import okhttp3.Request
import java.io.IOException

Expand All @@ -20,7 +21,7 @@ class Mp4UploadResolver : StreamResolver() {
private val regex = Regex("\"file\": \"(.+)\"")

@Throws(IOException::class)
override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
val response = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.get()
.url(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class MyviResolver : StreamResolver() {

override val name = "Myvi"

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
val response = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.get()
.url("http://myvi.ru/player/api/Video/Get/${HttpUrl.parse(url).pathSegments().last()}?sig")
.url("http://myvi.ru/player/api/Video/Get/${url.pathSegments().last()}?sig")
.build()).execute()

val resultUrl = ProxerConnectionWrapper.moshi.adapter(SprutoResult::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.ProxerConnectionWrapper
import okhttp3.HttpUrl
import okhttp3.Request

/**
Expand All @@ -19,7 +20,7 @@ class NovamovStreamResolver : StreamResolver() {
private val keyRegex = Regex("file=\"(.*?)\".*filekey=\"(.*?)\"", RegexOption.DOT_MATCHES_ALL)
private val urlRegex = Regex("url=(.*?)&title")

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
val response = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
.get()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.proxerme.app.stream.resolver

import android.net.Uri
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.extension.androidUri
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -13,7 +14,7 @@ class ProsiebenMAXXResolver : StreamResolver() {

override val name = "ProSieben MAXX"

override fun resolve(url: String): StreamResolutionResult {
return StreamResolutionResult(Uri.parse(url), "text/html")
override fun resolve(url: HttpUrl): StreamResolutionResult {
return StreamResolutionResult(url.androidUri(), "text/html")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.ProxerConnectionWrapper
import okhttp3.HttpUrl
import okhttp3.Request

/**
Expand All @@ -18,7 +19,7 @@ class ProxerStreamResolver : StreamResolver() {

private val regex = Regex("<source type=\"(.*?)\" src=\"(.*?)\">")

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
val response = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.get()
.url(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.ProxerConnectionWrapper
import okhttp3.FormBody
import okhttp3.HttpUrl
import okhttp3.Request

/**
Expand All @@ -20,7 +21,7 @@ class StreamcloudResolver : StreamResolver() {
private val fromRegex = Regex("<input.*?name=\"(.*?)\".*?value=\"(.*?)\">")
private val fileRegex = Regex("file: \"(.+?)\",")

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
var response = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.get()
.url(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionException
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.ProxerConnectionWrapper
import okhttp3.HttpUrl
import okhttp3.Request

/**
Expand All @@ -19,7 +20,7 @@ class VideoWeedStreamResolver : StreamResolver() {
private val keyRegex = Regex("fkz=\"(.*?)\".*file=\"(.*?)\"", RegexOption.DOT_MATCHES_ALL)
private val urlRegex = Regex("url=(.*?)&title")

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
val response = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
.get()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.proxerme.app.stream.resolver

import android.net.Uri
import com.proxerme.app.stream.StreamResolver
import com.proxerme.app.task.StreamResolutionTask.StreamResolutionResult
import com.proxerme.app.util.extension.androidUri
import okhttp3.HttpUrl

/**
* TODO: Describe class
Expand All @@ -13,7 +14,7 @@ class ViewsterResolver : StreamResolver() {

override val name = "Viewster"

override fun resolve(url: String): StreamResolutionResult {
return StreamResolutionResult(Uri.parse(url), "text/html")
override fun resolve(url: HttpUrl): StreamResolutionResult {
return StreamResolutionResult(url.androidUri(), "text/html")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class YourUploadResolver : StreamResolver() {

private val regex = Regex("file: '(.*?)'")

override fun resolve(url: String): StreamResolutionResult {
override fun resolve(url: HttpUrl): StreamResolutionResult {
val response = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.get()
.url(url)
Expand All @@ -35,7 +35,7 @@ class YourUploadResolver : StreamResolver() {
}

val apiResponse = ProxerConnectionWrapper.httpClient.newCall(Request.Builder()
.header("Referer", url)
.header("Referer", url.toString())
.head()
.url(HttpUrl.parse("http://yourupload.com$file"))
.build()).execute()
Expand Down
Loading

0 comments on commit d20c003

Please sign in to comment.