Skip to content

Commit

Permalink
add static searchable hashes (#110)
Browse files Browse the repository at this point in the history
* add utr/qxr/vyndros/tigole hashes

* `2.11`
  • Loading branch information
dpozinen authored Feb 4, 2024
1 parent ae25f52 commit 133abb0
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 3 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = 'dpozinen'
version = '2.10'
version = '2.11'

repositories {
mavenCentral()
Expand All @@ -16,6 +16,7 @@ repositories {

dependencies {
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'com.jayway.jsonpath:json-path:2.9.0'
implementation 'org.springframework.boot:spring-boot-starter-web:3.1.4'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1'
implementation 'io.github.microutils:kotlin-logging-jvm:2.1.21'
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/dpozinen/tracker/Torrent.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dpozinen.tracker

data class Torrent(
val link: String, val name: String,
val link: String = "", val name: String,
val size: String = "",
val seeds: Int = 0, val leeches: Int = 0,
val date: String = "",
Expand Down
6 changes: 6 additions & 0 deletions src/main/kotlin/dpozinen/tracker/Tracker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Tracker(
when (tracker) {
Trackers.OneThreeThree -> oneThreeThreeSevenXTo()
Trackers.TorrentGalaxy -> torrentGalaxy()
Trackers.Trunk -> trunk()
}

private fun oneThreeThreeSevenXTo() = Tracker(
Expand All @@ -39,6 +40,11 @@ class Tracker(
TrackerOps.TorrentGalaxy()
)

private fun trunk() = Tracker(
TrackerParser.Trunk(),
TrackerOps.Trunk()
)

}

}
36 changes: 36 additions & 0 deletions src/main/kotlin/dpozinen/tracker/TrackerOps.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package dpozinen.tracker

import com.jayway.jsonpath.Configuration
import com.jayway.jsonpath.JsonPath
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider
import org.jsoup.Connection
import org.jsoup.Jsoup
import java.nio.file.Files
import java.nio.file.Path
import kotlin.io.path.isRegularFile

interface TrackerOps {

Expand Down Expand Up @@ -43,6 +49,36 @@ interface TrackerOps {

}

class Trunk : TrackerOps {
private val dir = Path.of(this.javaClass.getResource("/hashes")!!.toURI())
private val jsonConfig = Configuration.builder().mappingProvider(JacksonMappingProvider()).build()

override fun open(torrent: Torrent) = ""

override fun search(keywords: List<String>): String {
return Files.walk(dir)
.parallel()
.filter { it.isRegularFile() }
.flatMap { collectMatches(it, keywords).stream() }
.toList()
.let { JsonPath.parse(it).jsonString() }
}

override fun expandUrl(url: String) = ""

private fun collectMatches(path: Path, keywords: List<String>): List<String> {
return JsonPath.parse(path.toFile(), jsonConfig)
.read("$.*.[?]", { matches(keywords, it.item(Map::class.java)) })
}

private fun matches(keywords: List<String>, candidate: Map<*, *>): Boolean {
val name = candidate["name"] as String

return keywords.count { name.lowercase().contains(it.lowercase()) } == keywords.size
}

}

companion object {
val session: Connection = Jsoup.newSession()
}
Expand Down
25 changes: 25 additions & 0 deletions src/main/kotlin/dpozinen/tracker/TrackerParser.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package dpozinen.tracker

import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
import com.fasterxml.jackson.databind.json.JsonMapper
import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder
import mu.KotlinLogging.logger
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import java.net.URLEncoder
import java.nio.charset.Charset

interface TrackerParser {

Expand Down Expand Up @@ -100,4 +106,23 @@ interface TrackerParser {

}

class Trunk : TrackerParser {
private val mapper: JsonMapper = jacksonMapperBuilder()
.configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
.build()

private val ref = object : TypeReference<List<Torrent>>() {}

override fun parseSearch(body: String): Torrents {
val torrents = mapper.readValue(body, ref).map { it.copy(link = toMagnet(it)) }
return Torrents(torrents)
}

private fun toMagnet(torrent: Torrent): String {
val name = URLEncoder.encode(torrent.name, Charset.defaultCharset())
return "magnet:?xt=urn:btih:${torrent.link}&dn=$name"
}

override fun parseTorrentPage(body: String) = Torrent(name = "")
}
}
3 changes: 2 additions & 1 deletion src/main/kotlin/dpozinen/tracker/Trackers.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package dpozinen.tracker

enum class Trackers {
OneThreeThree, TorrentGalaxy;
OneThreeThree, TorrentGalaxy, Trunk;

companion object {
fun from(name: String) = when (name) {
"133" -> OneThreeThree
"torrent-galaxy" -> TorrentGalaxy
"trunk" -> Trunk
else -> throw IllegalArgumentException()
}
}
Expand Down
88 changes: 88 additions & 0 deletions src/main/resources/application-trackers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
tracker-ops:
tracker:
announce-list:
- udp://tracker.opentrackr.org:1337/announce
- udp://tracker.dler.com:6969/announce
- http://tracker.bt4g.com:2095/announce
- http://open.acgnxtracker.com:80/announce
- udp://tracker2.dler.com:80/announce
- udp://movies.zsw.ca:6969/announce
- udp://tracker.torrent.eu.org:451/announce
- https://tr.burnabyhighstar.com:443/announce
- udp://open.xxtor.com:3074/announce
- https://tracker.loligirl.cn:443/announce
- https://tracker1.520.jp:443/announce
- udp://uploads.gamecoast.net:6969/announce
- https://tracker.tamersunion.org:443/announce
- udp://tracker.edkj.club:6969/announce
- http://p2p.0g.cx:6969/announce
- https://trackers.mlsub.net:443/announce
- udp://opentracker.io:6969/announce
- http://tracker.renfei.net:8080/announce
- udp://oh.fuuuuuck.com:6969/announce
- udp://ec2-18-191-163-220.us-east-2.compute.amazonaws.com:6969/announce
- udp://ttk2.nbaonlineservice.com:6969/announce
- udp://y.paranoid.agency:6969/announce
- https://tracker.yemekyedim.com:443/announce
- udp://tracker.torrust-demo.com:6969/announce
- udp://martin-gebhardt.eu:25/announce
- http://aboutbeautifulgallopinghorsesinthegreenpasture.online:80/announce
- https://shahidrazi.online:443/announce
- udp://tracker.picotorrent.one:6969/announce
- udp://open.stealth.si:80/announce
- http://tracker.files.fm:6969/announce
- udp://moonburrow.club:6969/announce
- udp://tracker.cubonegro.lol:6969/announce
- udp://ns1.monolithindustries.com:6969/announce
- udp://tracker.0x7c0.com:6969/announce
- udp://tracker.therarbg.com:6969/announce
- udp://tracker.fnix.net:6969/announce
- https://tr.qfruiti.com:443/announce
- https://tr.qfruiti.in:443/announce
- https://www.peckservers.com:9443/announce
- udp://odd-hd.fr:6969/announce
- http://bt.okmp3.ru:2710/announce
- http://bvarf.tracker.sh:2086/announce
- udp://tracker.filemail.com:6969/announce
- udp://d40969.acod.regrucolo.ru:6969/announce
- http://t.acg.rip:6699/announce
- udp://tracker.tryhackx.org:6969/announce
- https://t1.hloli.org:443/announce
- udp://www.torrent.eu.org:451/announce
- udp://bt1.archive.org:6969/announce
- udp://epider.me:6969/announce
- udp://tracker.mirrorbay.org:6969/announce
- udp://api.alarmasqueretaro.com:3074/announce
- http://tracker.mywaifu.best:6969/announce
- udp://thinking.duckdns.org:6969/announce
- udp://tracker.t-rb.org:6969/announce
- udp://exodus.desync.com:6969/announce
- https://tracker.lilithraws.cf:443/announce
- udp://retracker.lanta.me:2710/announce
- https://tracker.lilithraws.org:443/announce
- udp://1c.premierzal.ru:6969/announce
- udp://explodie.org:6969/announce
- udp://6ahddutb1ucc3cp.ru:6969/announce
- udp://tracker.qu.ax:6969/announce
- udp://tamas3.ynh.fr:6969/announce
- udp://u4.trakx.crim.ist:1337/announce
- udp://su-data.com:6969/announce
- https://bot.ponomar-sibir.ru:443/announce
- http://tracker1.itzmx.com:8080/announce
- udp://6.pocketnet.app:6969/announce
- udp://evan.im:6969/announce
- udp://bittorrent-tracker.e-n-c-r-y-p-t.net:1337/announce
- udp://opentracker.i2p.rocks:6969/announce
- udp://tk1.trackerservers.com:8080/announce
- udp://open.dstud.io:6969/announce
- https://tracker.gcrreen.xyz:443/announce
- udp://wepzone.net:6969/announce
- udp://tracker.srv00.com:6969/announce
- https://tracker.cloudit.top:443/announce
- udp://bt2.archive.org:6969/announce
- http://tracker.gbitt.info:80/announce
- udp://tracker-udp.gbitt.info:80/announce
- udp://new-line.net:6969/announce
- udp://tracker.therarbg.to:6969/announce
- udp://black-bird.ynh.fr:6969/announce
- udp://tracker.anima.nz:6969/announce
1 change: 1 addition & 0 deletions src/main/resources/hashes/qxr.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main/resources/hashes/tigole.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main/resources/hashes/utr.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/main/resources/hashes/vyndros.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<input type="radio" class="form-check-input btn-check" name="tracker" id="torrent-galaxy" value="torrent-galaxy" autocomplete="off">
<label class="form-check-label btn btn-outline-secondary" for="torrent-galaxy">torrentgalaxy.to</label>
</div>
<div class="form-check form-check-inline">
<input type="radio" class="form-check-input btn-check" name="tracker" id="trunk" value="trunk" autocomplete="off">
<label class="form-check-label btn btn-outline-secondary" for="trunk">trunk</label>
</div>
<div class="mb-5"></div>
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
Expand Down
29 changes: 29 additions & 0 deletions src/test/kotlin/tracker/TrunkTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package tracker

import dpozinen.tracker.TrackerOps
import dpozinen.tracker.TrackerParser
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.data.Index.atIndex
import kotlin.test.Test

class TrunkTest {

@Test
fun `should search for dune (2021) in 4k`() {
val torrents = TrackerOps.Trunk().search(listOf("Dune", "2021", "2160p"))

assertThat(TrackerParser.Trunk().parseSearch(torrents).torrents).hasSize(2)
.satisfies({
assertThat(it.link)
.isEqualTo("magnet:?xt=urn:btih:F380DF80EAF77BBD91920D10AE66DB49C846EE63&dn=Dune-2021-2160p-BluRay-x265-HEVC-10bit-HDR-AAC-7-1-Tigole-QxR")
}, atIndex(0))
}

@Test
fun `should search for dune in 4k`() {
val torrents = TrackerOps.Trunk().search(listOf("Dune", "2160p"))

assertThat(TrackerParser.Trunk().parseSearch(torrents).torrents).hasSize(5)
}

}

0 comments on commit 133abb0

Please sign in to comment.