-
Notifications
You must be signed in to change notification settings - Fork 5
Added covers, fixed getting all torrents #39
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
base: master
Are you sure you want to change the base?
Conversation
lnxx-56
commented
Oct 18, 2024
- Fixed issue that prevented to call the search function with the number=None argument
- Added poster images to be included in torrent object
- Fixed issue that prevented to call the search function with the number=None argument - Added poster images to be included in torrent object
This comment was marked as resolved.
This comment was marked as resolved.
- Fixed infinit loop when not defining number, -1 means give me all torrent - Fixed issue regarding the torrents which does not have any poster
radaron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested with this torrent id: 3291254 where there is a cover, but it tells no cover.
I think something is wrong with the regex pattern
Co-authored-by: Aron Radics <radics.aron.jozsef@gmail.com>
| page_count = 1 | ||
| torrents = [] | ||
| while number is None or len(torrents) < number: | ||
| while number is None or number == -1 or len(torrents) < number: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
| f"key with pattern: {key_pattern}") | ||
|
|
||
|
|
||
| def id_exists(self, data, search_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be staticmethod and can start with _
| if (len(ids_names) != len(ids_names_posters)): | ||
| for i, id in enumerate(ids_names): | ||
| if not self.id_exists(ids_names_posters, ids_names[i][0]): | ||
| missing_torrent_data = (ids_names[i][0], ids_names[i][1], 'no cover') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The no Cover could be a constant. Because in one place no cover in another No cover
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in data.py you can create a NO_COVER constant and use here.
| else: | ||
| if not self.not_found_pattern.search(data): | ||
| raise NcoreParserError(f"Error while parse download items in {self.__class__.__name__}.") | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This return hides an error. If the len of found data is not equal.
| r'<a href=".*?" onclick="torrent\((\d+)\);.*?" title="(.*?)">.*?(?:onmouseover="mutat\(\'(https:\/\/.*?)\',.*?)', | ||
| re.DOTALL | ||
| ) | ||
| self.id_name_patter = re.compile(r'<a href=".*?" onclick="torrent\(([0-9]+)\); return false;" title="(.*?)">') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: pattern
| self.type_pattern = re.compile(r'<a href=".*\/torrents\.php\?tipus=(.*?)">' | ||
| r'<img src=".*" class="categ_link" alt=".*" title=".*">') | ||
| self.id_name_pattern = re.compile(r'<a href=".*?" onclick="torrent\(([0-9]+)\); return false;" title="(.*?)">') | ||
| self.id_name_poster_pattern = re.compile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend to use simpler regex here. As I see there is the image tag:
<img onmouseout="elrejt('borito3814785')" onmouseover="mutat('https://nc-img.cdn.l7cache.com/covers/L9_kjpbQ9UwZFlXZ?28795815', '281', 'borito3814785', this)" border="0" src="data:image/gif;base64,R0lGODlhDwAPAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAAPAA8AAAINlI+py+0Po5y02otnAQA7" class="infobar_ico">
And here you could parse out the torrent id: elrejt('borito3814785') the id is: 3814785.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you can iterate over the ids. check is the id in this pattern output. If yes add if not set no cover.
| sizes = self.size_pattern.findall(data) | ||
| seed = self.seeders_pattern.findall(data) | ||
| leech = self.leechers_pattern.findall(data) | ||
| if len(types) != 0 and len(types) == len(ids_names) == \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create a poster dict here, where the key is the torrent id and the value is the poster url or "no cover".
You can iterate on IDs, and add the id to this dict key, then find the poster image and add as value.
For this I recommend to convert the re.findall response to a dictionary:
https://www.geeksforgeeks.org/python-convert-a-list-of-tuples-into-dictionary/
Co-authored-by: Aron Radics <radics.aron.jozsef@gmail.com>