radiorabe / suisa_sendemeldung

ACRCloud client for SUISA reporting @ RaBe.
https://radiorabe.github.io/suisa_sendemeldung/
MIT License
1 stars 2 forks source link

`funge_release_date` fails when API returns bad timestamp #261

Closed spameier closed 1 year ago

spameier commented 1 year ago

I had this stacktrace:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/user/suisa_sendemeldung/suisa_sendemeldung/suisa_sendemeldung.py", line 793, in <module>
    main()
  File "/home/user/suisa_sendemeldung/suisa_sendemeldung/suisa_sendemeldung.py", line 738, in main
    data = get_xlsx(data, station_name=args.station_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/suisa_sendemeldung/suisa_sendemeldung/suisa_sendemeldung.py", line 569, in get_xlsx
    csv = get_csv(data, station_name=station_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/suisa_sendemeldung/suisa_sendemeldung/suisa_sendemeldung.py", line 517, in get_csv
    release_date = funge_release_date(music.get("release_date", ""))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/suisa_sendemeldung/suisa_sendemeldung/suisa_sendemeldung.py", line 379, in funge_release_date
    return datetime.strptime(release_date, "%Y-%m-%d").strftime("%Y%m%d")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '0000-00-00' does not match format '%Y-%m-%d'
hairmare commented 1 year ago

I found another case:

ValueError: time data '02-16-2022' does not match format '%Y-%m-%d'