From 0f1cc4309768788c639249c8bf4028f1b231e5a5 Mon Sep 17 00:00:00 2001
From: James Taylor <user234683@users.noreply.github.com>
Date: Mon, 6 Aug 2018 20:28:41 -0700
Subject: fix shelves breaking channel videos page

---
 youtube/channel.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/youtube/channel.py b/youtube/channel.py
index 5751b95..9165b15 100644
--- a/youtube/channel.py
+++ b/youtube/channel.py
@@ -64,8 +64,10 @@ def channel_ctoken(channel_id, page, sort, tab, view=1):
     tab = proto.string(2, tab )
     sort = proto.uint(3, int(sort))
     page = proto.string(15, str(page) )
+    # example with shelves in videos tab: https://www.youtube.com/channel/UCNL1ZadSjHpjm4q9j2sVtOA/videos
+    shelf_view = proto.uint(4, 0)
     view = proto.uint(6, int(view))
-    continuation_info = proto.string( 3, proto.percent_b64encode(tab + view + sort + page) )
+    continuation_info = proto.string( 3, proto.percent_b64encode(tab + view + sort + shelf_view + page) )
     
     channel_id = proto.string(2, channel_id )
     pointless_nest = proto.string(80226972, channel_id + continuation_info)
@@ -360,7 +362,7 @@ def get_user_page(url, query_string=''):
     except IndexError:
         page = 'videos'
     if page == 'videos':
-        polymer_json = common.fetch_url('https://www.youtube.com/user/' + username + '/videos?pbj=1', headers_1)
+        polymer_json = common.fetch_url('https://www.youtube.com/user/' + username + '/videos?pbj=1&view=0', headers_1)
         polymer_json = json.loads(polymer_json)
         return channel_videos_html(polymer_json)
     elif page == 'about':
-- 
cgit v1.2.3