diff --git a/tubearchivist/home/src/helper.py b/tubearchivist/home/src/helper.py index 5f9ffc1..0ac2a11 100644 --- a/tubearchivist/home/src/helper.py +++ b/tubearchivist/home/src/helper.py @@ -46,7 +46,7 @@ def process_url_list(url_str): url_list = re.split('\n+', url_str[0]) youtube_ids = [] for url in url_list: - url_clean = url.strip().split('/')[-1] + url_clean = url.strip().strip('/').split('/')[-1] for i in to_replace: url_clean = url_clean.replace(i, '') url_no_param = url_clean.split('&')[0] diff --git a/tubearchivist/home/templates/home/channel.html b/tubearchivist/home/templates/home/channel.html index 490d42e..4ba6f7a 100644 --- a/tubearchivist/home/templates/home/channel.html +++ b/tubearchivist/home/templates/home/channel.html @@ -5,26 +5,29 @@

Channels

-
-
-

Subscribe to channel

-

Input channel ID, channel URL or Video of a channel

-
- {% csrf_token %} - - -
+
+
+ add-icon +

Subscribe to Channels

+
+
+ {% csrf_token %} + + +
+
-
+
+
+ search-icon +

Search Channels

+
-
- search-icon -
diff --git a/tubearchivist/home/templates/home/home.html b/tubearchivist/home/templates/home/home.html index c91fe12..9ddeb4a 100644 --- a/tubearchivist/home/templates/home/home.html +++ b/tubearchivist/home/templates/home/home.html @@ -4,33 +4,31 @@

Recent Videos

-
+
-
-

Sort order from {{ sortorder }} +

Sort order from {{ sortorder }}

-
-
-

Hide watched videos {{ hide_watched }} + +

+

Hide watched videos {{ hide_watched }}

-
+ +

-
+
+
+ search-icon +
-
- search-icon -
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index b978073..5768c83 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -314,28 +314,41 @@ class ChannelView(View): colors = config['application']['colors'] return es_url, colors - @staticmethod - def post(request): + def post(self, request): """ handle http post requests """ subscriptions_post = dict(request.POST) print(subscriptions_post) subscriptions_post = dict(request.POST) if 'subscribe' in subscriptions_post.keys(): - youtube_ids = process_url_list(subscriptions_post['subscribe']) - if youtube_ids[0]['type'] == 'video': - youtube_id = youtube_ids[0]['url'] - vid_details = PendingList().get_youtube_details(youtube_id) + sub_str = subscriptions_post['subscribe'] + try: + youtube_ids = process_url_list(sub_str) + self.subscribe_to(youtube_ids) + except ValueError: + print('parsing subscribe ids failed!') + print(sub_str) + + sleep(1) + return redirect('channel', permanent=True) + + @staticmethod + def subscribe_to(youtube_ids): + """ process the subscribe ids """ + for youtube_id in youtube_ids: + if youtube_id['type'] == 'video': + to_sub = youtube_id['url'] + vid_details = PendingList().get_youtube_details(to_sub) channel_id_sub = vid_details['channel_id'] + elif youtube_id['type'] == 'channel': + channel_id_sub = youtube_id['url'] else: - channel_id_sub = youtube_ids[0]['url'] + raise ValueError('failed to subscribe to: ' + youtube_id) + ChannelSubscription().change_subscribe( channel_id_sub, channel_subscribed=True ) print('subscribed to: ' + channel_id_sub) - sleep(1) - return redirect('channel', permanent=True) - class VideoView(View): """ resolves to /video// diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index f684884..2762a31 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -182,11 +182,7 @@ button:hover { .sort { display: flex; flex-wrap: wrap; -} - -.sort > div { - width: 100%; - display: inline; + align-content: center; } .padding-box { @@ -201,13 +197,6 @@ button:hover { width: 50%; } -.search-form { - display: flex; - flex-wrap: wrap; - align-items: center; - justify-content: flex-end; -} - .search-form input { width: 90%; } @@ -615,9 +604,6 @@ button:hover { .sort { display: block; } - .sort > div { - display: block; - } .sort select { width: 100%; margin: unset;