Exemplo n.º 1
0
    def get(self, from_date: datetime,
            to_date: datetime) -> List[AudiovisualRecord]:
        headers = {'Accept-Language': 'en,es;q=0.9,pt;q=0.8'}
        session = PhantomBrowsingSession(referer=self.base_url + '/',
                                         headers=headers)
        session.get(self.get_search_url(from_date, to_date), timeout=30)
        response = session.last_response
        if response is None or not self.results_found(response.content):
            return []
        audiovisual_records = []
        names = self.extract_all_names(response.content)
        links = self.extract_all_detail_pages(response.content)
        for n, name in enumerate(names):
            link = links[n]
            audiovisual_record = AudiovisualRecord(name=name)
            self._prepare_metadata_dict(audiovisual_record)
            audiovisual_record.metadata['detailed_page'][
                self.source_name] = link
            audiovisual_records.append(audiovisual_record)

        return audiovisual_records
Exemplo n.º 2
0
def add_audiovisual_record_by_name(name, **additional_attributes):
    record = AudiovisualRecord(name=name, **additional_attributes)
    dao_implementation.save_audiovisual_record(record)