Skip to content

Commit

Permalink
- Rollback workaround over youtube next-page bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KOL committed Jun 3, 2015
1 parent cb0e4c1 commit cd6afe7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 50 deletions.
19 changes: 5 additions & 14 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,16 +669,12 @@ def AddPlaylists(oc, uid, offset=None):
return oc


def AddSubscriptions(oc, uid, offset=0):

# TODO - temporary workaround while YT bug not fixed
offset = int(offset)
limit = GetLimitForOC(oc)
def AddSubscriptions(oc, uid, offset=None):

res = ApiRequest('subscriptions', ApiGetParams(
uid=uid,
limit=limit,
offset=Video.CalculateOffset(offset),
limit=GetLimitForOC(oc),
offset=offset,
order=str(Prefs['subscriptions_order']).lower()
))

Expand All @@ -697,13 +693,8 @@ def AddSubscriptions(oc, uid, offset=0):
thumb=GetThumbFromSnippet(item),
))

# TODO - temporary workaround while YT bug not fixed
# if 'nextPageToken' in res:
# offset = res['nextPageToken']
offset += limit
if 'pageInfo' in res and (
res['pageInfo']['totalResults'] > offset
):
if 'nextPageToken' in res:
offset = res['nextPageToken']
oc.add(NextPageObject(
key=Callback(
Subscriptions,
Expand Down
36 changes: 0 additions & 36 deletions Contents/Services/Shared Code/video.pys
Original file line number Diff line number Diff line change
Expand Up @@ -154,42 +154,6 @@ def GetFromMainContent(item, key):
return ''


def CalculateOffset(position):
'''
Workaround for YT bug
https://code.google.com/p/gdata-issues/issues/detail?id=7163
Original on:
https://gist.github.com/bromix/d159787a63f9d7b00036
'''
if not position:
return None

low = 'AEIMQUYcgkosw048'
high = 'ABCDEFGHIJKLMNOP'
len_low = len(low)
len_high = len(high)

overflow_token = 'Q'
if position >= 128:
overflow_token_iteration = position // 128
overflow_token = '%sE' % high[overflow_token_iteration]
pass
low_iteration = position % len_low

# at this position the iteration starts with 'I' again (after 'P')
if position >= 256:
multiplier = (position // 128) - 1
position -= 128 * multiplier
pass
high_iteration = (position / len_low) % len_high

return 'C%s%s%sAA' % (
high[high_iteration],
low[low_iteration],
overflow_token
)


def DecryptSignature(s):
key = '-'.join([str(len(p)) for p in s.split('.')])
json_obj = JSON.ObjectFromURL(
Expand Down

0 comments on commit cd6afe7

Please sign in to comment.