v3 37
This commit is contained in:
parent
072cb2b192
commit
8bf709d899
@ -1,6 +1,6 @@
|
||||
import json
|
||||
from dataclasses import dataclass, asdict
|
||||
from typing import Any, List, Optional
|
||||
from typing import Any, Dict, List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
# Definer dataclassene for strukturen
|
||||
@ -46,7 +46,7 @@ def event_data_to_json(event_data: EventData) -> str:
|
||||
def json_to_media_event(json_data: str) -> MediaEvent:
|
||||
data_dict = json.loads(json_data)
|
||||
|
||||
metadata_dict = data_dict['metadata']
|
||||
metadata_dict: Dict[str, str] = data_dict['metadata']
|
||||
event_data_dict = data_dict['data']
|
||||
|
||||
metadata = EventMetadata(
|
||||
@ -55,7 +55,7 @@ def json_to_media_event(json_data: str) -> MediaEvent:
|
||||
referenceId=metadata_dict['referenceId'],
|
||||
status=metadata_dict['status'],
|
||||
created=parse_datetime(metadata_dict['created']),
|
||||
source=metadata_dict['source']
|
||||
source= metadata_dict.get('source', None)
|
||||
)
|
||||
|
||||
event_data = EventData(
|
||||
|
||||
@ -30,11 +30,11 @@ class Anii(SourceBase):
|
||||
if givenId:
|
||||
idToTitle[givenId] = _title
|
||||
results[givenId] = result
|
||||
except IndexError as notFound:
|
||||
except IndexError:
|
||||
pass
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
except IndexError as notFound:
|
||||
except IndexError:
|
||||
self.logNoMatch("Anii", titles=self.titles)
|
||||
pass
|
||||
except Exception as e:
|
||||
@ -73,11 +73,10 @@ class Anii(SourceBase):
|
||||
log.exception(e)
|
||||
return None
|
||||
|
||||
async def generate_id(self, text: str) -> Optional[str]:
|
||||
def generate_id(self, text: str) -> Optional[str]:
|
||||
if text:
|
||||
return await asyncio.to_thread(hashlib.md5, text.encode()).hexdigest()
|
||||
return hashlib.md5(text.encode()).hexdigest()
|
||||
return None
|
||||
|
||||
def getMediaType(self, type: str) -> str:
|
||||
return 'movie' if type.lower() == 'movie' else 'serie'
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user