Extras¶
Extras module for additional functionality related to RTN processing.
Functions:
Name | Description |
---|---|
- `title_match` |
Compare two titles using the Levenshtein ratio to determine similarity. |
- `sort_torrents` |
Sort a set of Torrent objects by their resolution and rank in descending order. |
- `extract_seasons` |
Extract season numbers from the title. |
- `extract_episodes` |
Extract episode numbers from the title. |
- `episodes_from_season` |
Extract episode numbers for a specific season from the title. |
For more details, please refer to the documentation.
episodes_from_season(raw_title, season_num)
¶
Only return episode numbers if the season number is found in the title and the season number matches the input season number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
`raw_title`
|
str
|
The original title of the torrent to analyze. |
required |
`season_num`
|
int
|
The season number to extract episodes for. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
|
Source code in RTN/extras.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
extract_episodes(raw_title)
¶
Extract episode numbers from the title or filename.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
`raw_title`
|
str
|
The original title of the torrent to analyze. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
|
Source code in RTN/extras.py
150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
extract_seasons(raw_title)
¶
Extract season numbers from the title or filename.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
`raw_title`
|
str
|
The original title of the torrent to analyze. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
|
Source code in RTN/extras.py
135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
get_lev_ratio(correct_title, parsed_title, threshold=0.85, aliases={})
¶
Compares two titles using the Levenshtein ratio to determine similarity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
`correct_title`
|
str
|
The reference title to compare against. |
required |
`parsed_title`
|
str
|
The title to compare with the reference title. |
required |
`threshold`
|
float
|
The similarity threshold to consider the titles as matching. |
required |
`aliases`
|
dict
|
A dictionary of aliases for the correct title. |
required |
Returns:
Type | Description |
---|---|
float
|
|
Source code in RTN/extras.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|
sort_torrents(torrents, bucket_limit=None)
¶
Sorts a set of Torrent objects by their resolution bucket and then by their rank in descending order. Returns a dictionary with infohash as keys and Torrent objects as values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
`torrents`
|
Set[Torrent]
|
A set of Torrent objects. |
required |
`bucket_limit`
|
int
|
The maximum number of torrents to return from each bucket. |
required |
Raises:
Type | Description |
---|---|
`TypeError`
|
If the input is not a set of Torrent objects. |
Returns:
Type | Description |
---|---|
Dict[str, Torrent]
|
|
Dict[str, Torrent]
|
with the torrent's infohash as the key. |
Source code in RTN/extras.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
title_match(correct_title, parsed_title, threshold=0.85, aliases={})
¶
Compares two titles using the Levenshtein ratio to determine similarity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
`correct_title`
|
str
|
The reference title to compare against. |
required |
`parsed_title`
|
str
|
The title to compare with the reference title. |
required |
`threshold`
|
float
|
The similarity threshold to consider the titles as matching. |
required |
`aliases`
|
dict
|
A dictionary of aliases for the correct title. |
required |
Returns:
bool
: True if the titles match, False otherwise.
Source code in RTN/extras.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|