-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: respect only torrent file avaliable scenario in anime-torrent-provider #138
Comments
So, if I'm following correctly, by |
Yes but it would disregard potential cookie authentication as I stated already so it might not be perfect solution. As far as I know animelayer is the only tracker which doesn't provide magnet links at all. Option 2 is preferable cause someone might need it eventually when implementing direct private tracker extension. I remember that's in not planned list so do as you see fit. Technically it's still possible to write extension for private tracker it just require messing up with code first which is not hard since it's always plaintext or host settings via http since extensions lack native support for them. I mean jackett API won't work without token either. |
Yeah, extensions can't store user info for now but for later versions I might add a feature to allow them to ask for config values that will be exposed in the code. To avoid issues though, these configs will be reset after every extension update.
I'm not really familiar with how to parse private tracker torrent to magnet links, Seanime also doesn't currently have a built-in way to do that. Also don't know how that would work towards cookie authentication since I guess in both cases the file needs to be downloaded (unless I'm wrong). |
I imagine the flow in second case that way: Extension domain -> On Working conversion exampleimport (
"bytes"
"encoding/base64"
"fmt"
"os"
"github.com/anacrolix/torrent/metainfo"
)
func b64torrent2magnet(base64Torrent string) (string, error) {
torrentData, err := base64.StdEncoding.DecodeString(base64Torrent)
if err != nil {
return "", err
}
torrentDataReader := bytes.NewReader(torrentData)
meta, err := metainfo.Load(torrentDataReader)
if err != nil {
return "", err
}
magnetLink, err := meta.MagnetV2()
if err != nil {
return "", err
}
return magnetLink.String(), nil
}
func main() {
content, _ := os.ReadFile("b64torrent.txt")
fmt.Println(b64torrent2magnet(string(content)))
} Extension site exampleclass Provider {
async getTorrentMagnetLink(torrent: AnimeTorrent): Promise<string> {
if(torrent.magnetLink) {
return torrent.magnetLink
}
if(!!torrent.downloadUrl) {
return ""
}
// Should be binary but i don't see blob in response definition this might break torrent
const data = await fetch(torrent.downloadUrl).then(e => e.text())
// Kinda try to restore original buffer
const buffer = CryptoJS.enc.Utf8.parse(data)
const b64 = CryptoJS.enc.Base64.stringify(buffer)
return b64torrent2magnet(b64) // globall call
}
} Base64 is optional cause i'm myself not sure how to pass raw buffers across host and extension. If you know the way please avoid base64. There's another option i was thinking of is to directly accept base64 encoded torrent file in |
Managed to make it work, so something like this will be possible async getTorrentMagnetLink(torrent: AnimeTorrent): Promise<string> {
if(torrent.magnetLink) return torrent.magnetLink
if(!torrent.downloadUrl) return ""
const data = await (await fetch(torrent.downloadUrl)).text()
return getMagnetLinkFromTorrentData(data)
} |
Checklist
Problem Description / Use Case
I'm writing extension to support jackett aggregator cause i need authentication/proxy for most trackers to work and turns out some trackers don't use magnets at all for example animelayer
part of jackett aggregated response
Proposed Solution
Although i can definitely try bundling parse-torrent from webtorrent i want to avoid doing so at all cost since it makes no sense when extension host can perform the conversion.
So any of this would be sufficient in my case
The text was updated successfully, but these errors were encountered: