define downloads mapping, serialize improvements
This commit is contained in:
parent
2ec9f9e78b
commit
fe50b413d5
|
|
@ -430,13 +430,15 @@
|
|||
{
|
||||
"index_name": "download",
|
||||
"expected_map": {
|
||||
"timestamp": {
|
||||
"type": "date",
|
||||
"format": "epoch_second"
|
||||
"auto_start": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"channel_id": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"channel_indexed": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"channel_name": {
|
||||
"type": "text",
|
||||
"fields": {
|
||||
|
|
@ -447,9 +449,23 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"duration": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"message": {
|
||||
"type": "text"
|
||||
},
|
||||
"published": {
|
||||
"type": "date",
|
||||
"format": "epoch_second||strict_date_optional_time"
|
||||
},
|
||||
"status": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "date",
|
||||
"format": "epoch_second"
|
||||
},
|
||||
"title": {
|
||||
"type": "text",
|
||||
"fields": {
|
||||
|
|
@ -460,24 +476,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"published": {
|
||||
"type": "date",
|
||||
"format": "epoch_second||strict_date_optional_time"
|
||||
},
|
||||
"vid_thumb_url": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"youtube_id": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"vid_type": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"auto_start": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"message": {
|
||||
"type": "text"
|
||||
"youtube_id": {
|
||||
"type": "keyword"
|
||||
}
|
||||
},
|
||||
"expected_set": {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class DownloadItemSerializer(serializers.Serializer):
|
|||
channel_indexed = serializers.BooleanField()
|
||||
channel_name = serializers.CharField()
|
||||
duration = serializers.CharField()
|
||||
message = serializers.CharField(required=False)
|
||||
published = serializers.CharField(allow_null=True)
|
||||
status = serializers.ChoiceField(
|
||||
choices=["pending", "ignore"], required=False
|
||||
|
|
@ -24,7 +25,6 @@ class DownloadItemSerializer(serializers.Serializer):
|
|||
vid_thumb_url = serializers.CharField(allow_null=True)
|
||||
vid_type = serializers.ChoiceField(choices=VideoTypeEnum.values())
|
||||
youtube_id = serializers.CharField()
|
||||
message = serializers.CharField(required=False)
|
||||
_index = serializers.CharField(required=False)
|
||||
_score = serializers.IntegerField(required=False)
|
||||
|
||||
|
|
|
|||
|
|
@ -369,16 +369,16 @@ class PendingList(PendingIndex):
|
|||
return None
|
||||
|
||||
to_add = {
|
||||
"youtube_id": video_data["id"],
|
||||
"title": video_data["title"],
|
||||
"vid_thumb_url": self._extract_thumb(video_data),
|
||||
"channel_id": video_data["channel_id"],
|
||||
"channel_indexed": video_data["channel_id"] in self.all_channels,
|
||||
"channel_name": video_data["channel"],
|
||||
"duration": get_duration_str(video_data.get("duration", 0)),
|
||||
"published": self._extract_published(video_data),
|
||||
"timestamp": int(datetime.now().timestamp()),
|
||||
"title": video_data["title"],
|
||||
"vid_thumb_url": self._extract_thumb(video_data),
|
||||
"vid_type": self._extract_vid_type(video_data),
|
||||
"channel_name": video_data["channel"],
|
||||
"channel_id": video_data["channel_id"],
|
||||
"channel_indexed": video_data["channel_id"] in self.all_channels,
|
||||
"youtube_id": video_data["id"],
|
||||
}
|
||||
serializer = DownloadItemSerializer(data=to_add)
|
||||
is_valid = serializer.is_valid()
|
||||
|
|
|
|||
Loading…
Reference in New Issue