Skip to content

Conversation

@lnxx-56
Copy link

@lnxx-56 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
@lnxx-56 lnxx-56 changed the title Added covers, fixed getting all torrent Added covers, fixed getting all torrents Oct 19, 2024
@radaron

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
Copy link
Owner

@radaron radaron left a 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

page_count = 1
torrents = []
while number is None or len(torrents) < number:
while number is None or number == -1 or len(torrents) < number:
Copy link
Owner

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):
Copy link
Owner

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')
Copy link
Owner

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

Copy link
Owner

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
Copy link
Owner

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="(.*?)">')
Copy link
Owner

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(
Copy link
Owner

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.

Copy link
Owner

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) == \
Copy link
Owner

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants