unchained-android
unchained-android copied to clipboard
[Plugin Development] Add table index parameter to search plugins
My source code so far... Domain in question: trupornolabs.org
The problem is that the table is not the first one on the page. I have no way to designate the correct table without there being id or class values. Any help would be highly appreciated.
Is there a way to count the tables in the html and select the correct table by counting?
PS: I also need to somehow skip the first TR in the tbody of the correct table.
I only need TRs of the class "gai".
{
"engine_version": 2.0,
"version": 1.0,
"url": "https://trupornolabs.org",
"name": "TruPornoLabs.org",
"description": "Parser for TruPornoLabs.org",
"author": "morpheasgr",
"supported_categories": {
"all": "None"
},
"search": {
"no_category": "${url}/search/${page}/0/1/2/${query}",
"page_start": 0
},
"download": {
"table_direct": {
"columns": {
"name_column": 1,
"seeders_column": 3,
"leechers_column": 3,
"size_column": 2,
"magnet_column": 1,
"torrent_column": 1,
"details_column": 1
}
},
"regexes": {
"magnet": {
"regex_use": "all",
"regexps": [
{
"regex": "href=\"(magnet:\\?xt=urn:btih:[^\"]+)",
"group": 1,
"slug_type": "complete"
}
]
},
"torrents": {
"regex_use": "first",
"regexps": [
{
"regex": "href=\"(https?:\/\/d.trupornolabs.org\/download\/[^\"]+)",
"group": 1,
"slug_type": "complete"
}
]
},
"name": {
"regex_use": "first",
"regexps": [
{
"regex": "^\\s+\"([^\"]+)",
"group": 1,
"slug_type": "complete"
}
]
},
"seeders": {
"regex_use": "first",
"regexps": [
{
"regex": "\"green\">(\\d*)",
"group": 1,
"slug_type": "complete"
}
]
},
"leechers": {
"regex_use": "first",
"regexps": [
{
"regex": "\"red\">(\\d*)",
"group": 1,
"slug_type": "complete"
}
]
},
"size": {
"regex_use": "first",
"regexps": [
{
"regex": "([\\w\\s.]*)",
"group": 1,
"slug_type": "complete"
}
]
},
"details": {
"regex_use": "first",
"regexps": [
{
"regex": "href=\"(\/torrent\/[^\"]+)",
"group": 1,
"slug_type": "append_url"
}
]
}
}
}
}
When you search a new table appears on top so you're right. I should add a parameter like table_index to let the parser know which table you need to use
@LivingWithHippos Is my approach to make this plugin correct though? I thought that the procedure is similar to Nyaa. I hope I got the indices and regex correct this time. I didn't add categories as the categories offered are custom and not the categories available to search plugins.
I want to support this project, but I'm mostly broke so I can't donate as much as I would want to, so I want to make myself useful by maybe writing search plugins or maybe one day making actually useful commits to the source code.
PS (off topic): Many apps utilizing RD, especially media apps, when searching for something specific actually spit back a list of results that are already "cached" by RD. I wonder how this is done, do they actually send a request for each and every magnet hash to see if is already cached? Is that easy to implement? Wouldn't it cause too many requests. Many Kodi add-ons and apps like Syncler, wako and Stremio add-ons do it. I wish I would have that info about all kinds of content types, including non-video ones.
Is my approach to make this plugin correct though
The plugin looks good, I had changed some regexes but it should work like this too.
I thought that the procedure is similar to Nyaa
Start from any plugin that has the same search mode (table direct in this case) and you'll be good
I want to support this project
I started this project to learn about Android programming and really few people have donated until now but that was expected so no problem. Now I have less time and the project is working good for me so I don't work on it as much as I used to
Many apps utilizing RD, especially media apps, when searching for something specific actually spit back a list of results that are already "cached" by RD. I wonder how this is done, do they actually send a request for each and every magnet hash to see if is already cached?
Looking at the apis at https://api.real-debrid.com/ it should be the /torrents/instantAvailability/{hash}
endpoint. You send the hash and it gives you a list of id of the files already cached on real debrid. Then if you select only those files they are already cached. It should not be hard to implement but I'd also need to implement file selection because at the moment unchained automatically select all the files in the torrent. #94
@LivingWithHippos Cached torrents would be great
Initial instantAvailability implementation could check the total number of files in a torrent/magnet either by scraping that info via the search plugins or by other means (fetching metadata, parsing, online APIs) and see if the number of hashes returned by RD is equal to the number of files we have. If less than equal but more than zero, mark as partial and on select add to cache (all files), if equal, mark as Cached and either add to "downloads"/generate streams (use existing cache) or add torrent as usual (this copies from cache) to include in user's cloud. RD also has a torrent info api section but it requires an ID, no hash so I don't know how it works. Adding a bunch of torrents or using select files to get info and then quickly deleting them is not a proper way of doing this... I wish their API was better documented or had more features.
By the way, bumping the request of table counting and order number as selector :) to stay on topic of the title.
you can now set "engine_version": 2.3
and add "index": 1
to "table_direct"
. You will also need to fix the search regexes a little