Skip to content

Commit

Permalink
torznab: add support for languages and subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed May 21, 2023
1 parent 9638823 commit 04e24ba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Jackett.Common/Indexers/Abstract/AvistazTracker.cs
Expand Up @@ -253,7 +253,9 @@ protected override async Task<IEnumerable<ReleaseInfo>> PerformQuery(TorznabQuer
DownloadVolumeFactor = row.Value<double>("download_multiply"),
UploadVolumeFactor = row.Value<double>("upload_multiply"),
MinimumRatio = 1,
MinimumSeedTime = 172800 // 48 hours
MinimumSeedTime = 172800, // 48 hours
Languages = row.Value<JArray>("audio")?.Select(x => x.Value<string>("language")).ToList() ?? new List<string>(),
Subs = row.Value<JArray>("subtitle")?.Select(x => x.Value<string>("language")).ToList() ?? new List<string>(),
};

releases.Add(release);
Expand Down
6 changes: 6 additions & 0 deletions src/Jackett.Common/Models/ReleaseInfo.cs
Expand Up @@ -26,6 +26,8 @@ public class ReleaseInfo : ICloneable
public long? TraktId { get; set; }
public long? DoubanId { get; set; }
public ICollection<string> Genres { get; set; }
public ICollection<string> Languages { get; set; }
public ICollection<string> Subs { get; set; }
public long? Year { get; set; }
public string Author { get; set; }
public string BookTitle { get; set; }
Expand All @@ -52,6 +54,8 @@ public class ReleaseInfo : ICloneable

public ReleaseInfo()
{
Languages = new List<string>();
Subs = new List<string>();
}

protected ReleaseInfo(ReleaseInfo copyFrom)
Expand All @@ -74,6 +78,8 @@ protected ReleaseInfo(ReleaseInfo copyFrom)
TraktId = copyFrom.TraktId;
DoubanId = copyFrom.DoubanId;
Genres = copyFrom.Genres;
Languages = copyFrom.Languages;
Subs = copyFrom.Subs;
Year = copyFrom.Year;
Author = copyFrom.Author;
BookTitle = copyFrom.BookTitle;
Expand Down
2 changes: 2 additions & 0 deletions src/Jackett.Common/Models/ResultPage.cs
Expand Up @@ -103,6 +103,8 @@ public string ToXml(Uri selfAtom)
GetTorznabElement("traktid", r.TraktId),
GetTorznabElement("doubanid", r.DoubanId),
r.Genres == null ? null : GetTorznabElement("genre", string.Join(", ", r.Genres)),
r.Languages == null ? null : from c in r.Languages select GetTorznabElement("language", c),
r.Subs == null ? null : from c in r.Subs select GetTorznabElement("subs", c),
GetTorznabElement("year", r.Year),
GetTorznabElement("author", RemoveInvalidXMLChars(r.Author)),
GetTorznabElement("booktitle", RemoveInvalidXMLChars(r.BookTitle)),
Expand Down

4 comments on commit 04e24ba

@ilike2burnthing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add this to cardigann as well?

Bump to v0.21.* for this?

@mynameisbogdan
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, sadly only AvistaZ properly supports this. I'm all for adding it to Cardigann, but I don't think we are there yet.

Bump to v0.21.* for this?

Yeah, it's been 0.20.x for too long. πŸ˜„

@ilike2burnthing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only just checking this now; I didn't realise that each language or subs is separate, e.g.:

      <torznab:attr name="language" value="English" />
      <torznab:attr name="language" value="Mandarin" />
      <torznab:attr name="subs" value="Chinese" />
      <torznab:attr name="subs" value="English" />

rather than a list, like genre, e.g.:

      <torznab:attr name="language" value="English,Mandarin" />
      <torznab:attr name="subs" value="Chinese,English" />

Had I taken more than a cursory glance at the code, that would have been obvious, but 🀷.

Would genre be better off like this as well? Or for that matter, would it be better for language and subs to be a list?

As far as I'm aware, nothing uses genre yet, so if we were to change it, now would probably be the best time.

@mynameisbogdan
Copy link
Contributor Author

@mynameisbogdan mynameisbogdan commented on 04e24ba May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already talked with Q on this topic (list vs string with comma), and we came to the conclusion that the spec isn't really definitive on this regard. Sonarr and Radarr already parses multiple occurrences of language, so let's leave it as list.

I would leave Genres as is, the spec has it with example as string separated by comma.

Please sign in to comment.