mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2024-09-20 15:27:15 +00:00
hide empty shorts and streams from page
This commit is contained in:
parent
7d6a879966
commit
d033573bd6
@ -8,9 +8,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="info-box-item channel-nav">
|
<div class="info-box-item channel-nav">
|
||||||
<a href="{% url 'channel_id' channel_info.channel_id %}"><h3>Videos</h3></a>
|
<a href="{% url 'channel_id' channel_info.channel_id %}"><h3>Videos</h3></a>
|
||||||
<a href="{% url 'channel_id_live' channel_info.channel_id %}"><h3>Live</h3></a>
|
{% if has_streams %}
|
||||||
|
<a href="{% url 'channel_id_live' channel_info.channel_id %}"><h3>Streams</h3></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if has_shorts %}
|
||||||
<a href="{% url 'channel_id_shorts' channel_info.channel_id %}"><h3>Shorts</h3></a>
|
<a href="{% url 'channel_id_shorts' channel_info.channel_id %}"><h3>Shorts</h3></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if has_playlists %}
|
||||||
<a href="{% url 'channel_id_playlist' channel_info.channel_id %}"><h3>Playlists</h3></a>
|
<a href="{% url 'channel_id_playlist' channel_info.channel_id %}"><h3>Playlists</h3></a>
|
||||||
|
{% endif %}
|
||||||
<a href="{% url 'channel_id_about' channel_info.channel_id %}"><h3>About</h3></a>
|
<a href="{% url 'channel_id_about' channel_info.channel_id %}"><h3>About</h3></a>
|
||||||
{% if has_pending %}
|
{% if has_pending %}
|
||||||
<a href="{% url 'downloads' %}?channel={{ channel_info.channel_id }}"><h3>Downloads</h3></a>
|
<a href="{% url 'downloads' %}?channel={{ channel_info.channel_id }}"><h3>Downloads</h3></a>
|
||||||
|
@ -8,9 +8,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="info-box-item channel-nav">
|
<div class="info-box-item channel-nav">
|
||||||
<a href="{% url 'channel_id' channel_info.channel_id %}"><h3>Videos</h3></a>
|
<a href="{% url 'channel_id' channel_info.channel_id %}"><h3>Videos</h3></a>
|
||||||
<a href="{% url 'channel_id_live' channel_info.channel_id %}"><h3>Live</h3></a>
|
{% if has_streams %}
|
||||||
|
<a href="{% url 'channel_id_live' channel_info.channel_id %}"><h3>Streams</h3></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if has_shorts %}
|
||||||
<a href="{% url 'channel_id_shorts' channel_info.channel_id %}"><h3>Shorts</h3></a>
|
<a href="{% url 'channel_id_shorts' channel_info.channel_id %}"><h3>Shorts</h3></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if has_playlists %}
|
||||||
<a href="{% url 'channel_id_playlist' channel_info.channel_id %}"><h3>Playlists</h3></a>
|
<a href="{% url 'channel_id_playlist' channel_info.channel_id %}"><h3>Playlists</h3></a>
|
||||||
|
{% endif %}
|
||||||
<a href="{% url 'channel_id_about' channel_info.channel_id %}"><h3>About</h3></a>
|
<a href="{% url 'channel_id_about' channel_info.channel_id %}"><h3>About</h3></a>
|
||||||
{% if has_pending %}
|
{% if has_pending %}
|
||||||
<a href="{% url 'downloads' %}?channel={{ channel_info.channel_id }}"><h3>Downloads</h3></a>
|
<a href="{% url 'downloads' %}?channel={{ channel_info.channel_id }}"><h3>Downloads</h3></a>
|
||||||
|
@ -8,9 +8,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="info-box-item channel-nav">
|
<div class="info-box-item channel-nav">
|
||||||
<a href="{% url 'channel_id' channel_info.channel_id %}"><h3>Videos</h3></a>
|
<a href="{% url 'channel_id' channel_info.channel_id %}"><h3>Videos</h3></a>
|
||||||
<a href="{% url 'channel_id_live' channel_info.channel_id %}"><h3>Live</h3></a>
|
{% if has_streams %}
|
||||||
|
<a href="{% url 'channel_id_live' channel_info.channel_id %}"><h3>Streams</h3></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if has_shorts %}
|
||||||
<a href="{% url 'channel_id_shorts' channel_info.channel_id %}"><h3>Shorts</h3></a>
|
<a href="{% url 'channel_id_shorts' channel_info.channel_id %}"><h3>Shorts</h3></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if has_playlists %}
|
||||||
<a href="{% url 'channel_id_playlist' channel_info.channel_id %}"><h3>Playlists</h3></a>
|
<a href="{% url 'channel_id_playlist' channel_info.channel_id %}"><h3>Playlists</h3></a>
|
||||||
|
{% endif %}
|
||||||
<a href="{% url 'channel_id_about' channel_info.channel_id %}"><h3>About</h3></a>
|
<a href="{% url 'channel_id_about' channel_info.channel_id %}"><h3>About</h3></a>
|
||||||
{% if has_pending %}
|
{% if has_pending %}
|
||||||
<a href="{% url 'downloads' %}?channel={{ channel_info.channel_id }}"><h3>Downloads</h3></a>
|
<a href="{% url 'downloads' %}?channel={{ channel_info.channel_id }}"><h3>Downloads</h3></a>
|
||||||
|
@ -489,6 +489,13 @@ class ChannelIdBaseView(ArchivistResultsView):
|
|||||||
|
|
||||||
return channel_info
|
return channel_info
|
||||||
|
|
||||||
|
def channel_pages(self, channel_id):
|
||||||
|
"""get additional context for channel pages"""
|
||||||
|
self.channel_has_pending(channel_id)
|
||||||
|
self.channel_has_streams(channel_id)
|
||||||
|
self.channel_has_shorts(channel_id)
|
||||||
|
self.channel_has_playlist(channel_id)
|
||||||
|
|
||||||
def channel_has_pending(self, channel_id):
|
def channel_has_pending(self, channel_id):
|
||||||
"""check if channel has pending videos in queue"""
|
"""check if channel has pending videos in queue"""
|
||||||
path = "ta_download/_search"
|
path = "ta_download/_search"
|
||||||
@ -502,11 +509,53 @@ class ChannelIdBaseView(ArchivistResultsView):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"_source": False,
|
||||||
}
|
}
|
||||||
response, _ = ElasticWrap(path).get(data=data)
|
response, _ = ElasticWrap(path).get(data=data)
|
||||||
|
|
||||||
self.context.update({"has_pending": bool(response["hits"]["hits"])})
|
self.context.update({"has_pending": bool(response["hits"]["hits"])})
|
||||||
|
|
||||||
|
def channel_has_streams(self, channel_id):
|
||||||
|
"""check if channel has streams videos"""
|
||||||
|
data = self.get_type_data("streams", channel_id)
|
||||||
|
response, _ = ElasticWrap("ta_video/_search").get(data=data)
|
||||||
|
|
||||||
|
self.context.update({"has_streams": bool(response["hits"]["hits"])})
|
||||||
|
|
||||||
|
def channel_has_shorts(self, channel_id):
|
||||||
|
"""check if channel has shorts videos"""
|
||||||
|
data = self.get_type_data("shorts", channel_id)
|
||||||
|
response, _ = ElasticWrap("ta_video/_search").get(data=data)
|
||||||
|
|
||||||
|
self.context.update({"has_shorts": bool(response["hits"]["hits"])})
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_type_data(vid_type, channel):
|
||||||
|
"""build data query for vid_type"""
|
||||||
|
return {
|
||||||
|
"size": 1,
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"must": [
|
||||||
|
{"term": {"vid_type": {"value": vid_type}}},
|
||||||
|
{"term": {"channel.channel_id": {"value": channel}}},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"_source": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
def channel_has_playlist(self, channel_id):
|
||||||
|
"""check if channel has any playlist indexed"""
|
||||||
|
path = "ta_playlist/_search"
|
||||||
|
data = {
|
||||||
|
"size": 1,
|
||||||
|
"query": {"term": {"playlist_channel_id": {"value": channel_id}}},
|
||||||
|
"_source": False,
|
||||||
|
}
|
||||||
|
response, _ = ElasticWrap(path).get(data=data)
|
||||||
|
self.context.update({"has_playlists": bool(response["hits"]["hits"])})
|
||||||
|
|
||||||
|
|
||||||
class ChannelIdView(ChannelIdBaseView):
|
class ChannelIdView(ChannelIdBaseView):
|
||||||
"""resolves to /channel/<channel-id>/
|
"""resolves to /channel/<channel-id>/
|
||||||
@ -523,7 +572,7 @@ class ChannelIdView(ChannelIdBaseView):
|
|||||||
self._update_view_data(channel_id)
|
self._update_view_data(channel_id)
|
||||||
self.find_results()
|
self.find_results()
|
||||||
self.match_progress()
|
self.match_progress()
|
||||||
self.channel_has_pending(channel_id)
|
self.channel_pages(channel_id)
|
||||||
|
|
||||||
if self.context["results"]:
|
if self.context["results"]:
|
||||||
channel_info = self.context["results"][0]["source"]["channel"]
|
channel_info = self.context["results"][0]["source"]["channel"]
|
||||||
@ -610,7 +659,7 @@ class ChannelIdAboutView(ChannelIdBaseView):
|
|||||||
def get(self, request, channel_id):
|
def get(self, request, channel_id):
|
||||||
"""handle get request"""
|
"""handle get request"""
|
||||||
self.initiate_vars(request)
|
self.initiate_vars(request)
|
||||||
self.channel_has_pending(channel_id)
|
self.channel_pages(channel_id)
|
||||||
|
|
||||||
response, _ = ElasticWrap(f"ta_channel/_doc/{channel_id}").get()
|
response, _ = ElasticWrap(f"ta_channel/_doc/{channel_id}").get()
|
||||||
channel_info = SearchProcess(response).process()
|
channel_info = SearchProcess(response).process()
|
||||||
@ -658,7 +707,7 @@ class ChannelIdPlaylistView(ChannelIdBaseView):
|
|||||||
self.initiate_vars(request)
|
self.initiate_vars(request)
|
||||||
self._update_view_data(channel_id)
|
self._update_view_data(channel_id)
|
||||||
self.find_results()
|
self.find_results()
|
||||||
self.channel_has_pending(channel_id)
|
self.channel_pages(channel_id)
|
||||||
|
|
||||||
channel_info = self.get_channel_meta(channel_id)
|
channel_info = self.get_channel_meta(channel_id)
|
||||||
channel_name = channel_info["channel_name"]
|
channel_name = channel_info["channel_name"]
|
||||||
|
@ -649,6 +649,7 @@ video:-webkit-full-screen {
|
|||||||
|
|
||||||
.info-box-item {
|
.info-box-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
background-color: var(--highlight-bg);
|
background-color: var(--highlight-bg);
|
||||||
|
Loading…
Reference in New Issue
Block a user