diff --git a/.dockerignore b/.dockerignore index 66ada3ec..0d0fc7c3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,13 @@ # Docker .docker +# Backend development +backend/static +backend/staticfiles + +# Frontend development +frontend/node_modules + # Python tubearchivist/__pycache__/ tubearchivist/*/__pycache__/ diff --git a/.gitignore b/.gitignore index c5d22b51..812a03ba 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ __pycache__ # django testing backend/static +backend/staticfiles backend/.env # vscode custom conf diff --git a/backend/channel/src/index.py b/backend/channel/src/index.py index 6d03ed92..929aa5c9 100644 --- a/backend/channel/src/index.py +++ b/backend/channel/src/index.py @@ -56,12 +56,13 @@ class YoutubeChannel(YouTubeItem): def process_youtube_meta(self): """extract relevant fields""" self.youtube_meta["thumbnails"].reverse() + channel_name = self.youtube_meta["uploader"] or self.youtube_meta["id"] self.json_data = { "channel_active": True, "channel_description": self.youtube_meta.get("description", ""), "channel_id": self.youtube_id, "channel_last_refresh": int(datetime.now().timestamp()), - "channel_name": self.youtube_meta["uploader"], + "channel_name": channel_name, "channel_subs": self.youtube_meta.get("channel_follower_count", 0), "channel_subscribed": False, "channel_tags": self.youtube_meta.get("tags", []), @@ -157,8 +158,18 @@ class YoutubeChannel(YouTubeItem): # add ingest pipeline processors = [] for field, value in self.json_data.items(): - line = {"set": {"field": "channel." + field, "value": value}} + if value is None: + line = { + "script": { + "lang": "painless", + "source": f"ctx['{field}'] = null;", + } + } + else: + line = {"set": {"field": "channel." + field, "value": value}} + processors.append(line) + data = {"description": self.youtube_id, "processors": processors} ingest_path = f"_ingest/pipeline/{self.youtube_id}" _, _ = ElasticWrap(ingest_path).put(data) diff --git a/backend/common/src/watched.py b/backend/common/src/watched.py index d3d3b376..5cdef464 100644 --- a/backend/common/src/watched.py +++ b/backend/common/src/watched.py @@ -43,14 +43,9 @@ class WatchState: def change_vid_state(self): """change watched state of video""" path = f"ta_video/_update/{self.youtube_id}" - data = { - "doc": { - "player": { - "watched": self.is_watched, - "watched_date": self.stamp, - } - } - } + data = {"doc": {"player": {"watched": self.is_watched}}} + if self.is_watched: + data["doc"]["player"]["watched_date"] = self.stamp response, status_code = ElasticWrap(path).post(data=data) key = f"{self.user_id}:progress:{self.youtube_id}" RedisArchivist().del_message(key) diff --git a/frontend/src/components/ChannelList.tsx b/frontend/src/components/ChannelList.tsx index 90264a78..9bb42e50 100644 --- a/frontend/src/components/ChannelList.tsx +++ b/frontend/src/components/ChannelList.tsx @@ -49,7 +49,9 @@ const ChannelList = ({ channelList, refreshChannelList }: ChannelListProps) => {

{channel.channel_name}

- + {channel.channel_subs !== null && ( + + )}
diff --git a/frontend/src/components/ChannelOverview.tsx b/frontend/src/components/ChannelOverview.tsx index 1caecdbf..f26f631a 100644 --- a/frontend/src/components/ChannelOverview.tsx +++ b/frontend/src/components/ChannelOverview.tsx @@ -38,7 +38,7 @@ const ChannelOverview = ({ {channelname} - + {channelSubs !== null && } {isAdmin && ( <>