Skip to content
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

Fixed bugs in repositories/manganato.py #67

Merged
merged 1 commit into from Mar 8, 2024

Conversation

NokutokaMomiji
Copy link
Contributor

Issues with the Manganato repository source

Issues

  1. In the get method, the format string "%b %d,%Y - %I:%M %p" expects the hour to be in the 12-hour format. However, Manganato displays time in the 24-hour format, which triggers a ValueError exception.
from enma import Enma, DefaultAvailableSources

enma = Enma[DefaultAvailableSources]()
enma.source_manager.set_source("manganato")

test = enma.get(identifier="manga-um997395")

r"""
  File "D:\Archivos de Usuario\Escritorio\Stuff\Projects\external\Enma\enma\infra\adapters\repositories\manganato.py", line 152, in get
    created_at=datetime.strptime(updated_at, "%b %d,%Y - %I:%M %p") if updated_at else None,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Archivos de Programas\Python 3.11.2\Lib\_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Archivos de Programas\Python 3.11.2\Lib\_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data 'Mar 08,2024 - 14:47 PM' does not match format '%b %d,%Y - %I:%M %p'
"""
  1. The __create_title method assumes that the manga title will contain at least two alternatives. However, certain posts in Manganato have a singular alternative. Trying to unpack the values triggers a ValueError exception.
from enma import Enma, DefaultAvailableSources

enma = Enma[DefaultAvailableSources]()
enma.source_manager.set_source("manganato")

test = enma.get(identifier="manga-dj980492")

r"""
  File "D:\Archivos de Usuario\Escritorio\Stuff\Projects\external\Enma\enma\infra\adapters\repositories\manganato.py", line 124, in get
    title = self.__create_title(main_title=elem_title,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Archivos de Usuario\Escritorio\Stuff\Projects\external\Enma\enma\infra\adapters\repositories\manganato.py", line 48, in __create_title
    jp, cn, *_ = alternative.split(';') if alternative.find(';') != -1 else alternative.split(',')
    ^^^^^^^^^^
ValueError: not enough values to unpack (expected at least 2, got 1)
"""

Proposed solutions

  1. Change the format string from "%b %d,%Y - %I:%M %p" to "%b %d,%Y - %H:%M %p" to accept 24-hour formatted data.

  2. Add a check to see whether there are no multiple available alternative strings, and act accordingly.

has_many_alternatives = alternative.find(';') != -1 or alternative.find(',') != -1

if not has_many_alternatives:
    jp = alternative
    return Title(english=main_title.strip(),
                 japanese=jp.strip(),
                 other=main_title.strip())

@AlexandreSenpai AlexandreSenpai self-requested a review March 8, 2024 20:05
@AlexandreSenpai AlexandreSenpai added the bug Something isn't working label Mar 8, 2024
@AlexandreSenpai
Copy link
Owner

Approved.
Thank you very much for your contrib (●'◡'●)

@AlexandreSenpai AlexandreSenpai merged commit a17b0b5 into AlexandreSenpai:master Mar 8, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants