cnumr / ecoindex_python_fullstack

Refactoring of ecoindex in one monorepo using polylith pattern
Other
16 stars 4 forks source link

[Bug]: Error with mp3 #30

Closed vvatelot closed 8 months ago

vvatelot commented 9 months ago

What happened?

Error when trying to analyze an mp3 file

Project

Ecoindex Scraper

What OS do you use?

No response

urls

https://www.pascalfaure.com/hyper_relax/01_relaxation_corporelle.mp3

Relevant log output

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/celery/app/autoretry.py", line 60, in run
    ret = task.retry(exc=exc, **retry_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/celery/app/task.py", line 736, in retry
    raise_with_context(exc)
  File "/usr/local/lib/python3.12/site-packages/celery/app/autoretry.py", line 38, in run
    return task._orig_run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ecoindex/worker/tasks.py", line 36, in ecoindex_task
    queue_task_result = run(
                        ^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 684, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ecoindex/worker/tasks.py", line 52, in async_ecoindex_task
    ecoindex = await EcoindexScraper(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ecoindex/scraper/scrap.py", line 48, in get_page_analysis
    page_metrics = await self.scrap_page()
                   ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/ecoindex/scraper/scrap.py", line 90, in scrap_page
    return PageMetrics(
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pydantic/main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
ValueError

Code of Conduct

PaulPHPE commented 8 months ago

Hello @vvatelot !

I'm encountering a similar issue with a video file. The problem arises when the _transferSize in HTTP is set to -1, causing the script to malfunction when the total size is less than 0.

This issue occurs when loading audio and video messages. In instances where the server responds with "206 Partial Content," the _transferSize is assigned a value of -1. I suggest modifying the get_requests_from_har_file to accommodate the 206 response status. We can implement two checks:

I will make a PR, let me know