def ctoken_metadata(ctoken): result = dict() params = proto.parse(proto.b64_to_bytes(ctoken)) result['video_id'] = proto.parse(params[2])[2].decode('ascii') offset_information = proto.parse(params[6]) result['offset'] = offset_information.get(5, 0) result['is_replies'] = False if (3 in offset_information) and (2 in proto.parse(offset_information[3])): result['is_replies'] = True else: try: result['sort'] = proto.parse(offset_information[4])[6] except KeyError: result['sort'] = 0 return result
def get_ids(ctoken): params = proto.parse(proto.b64_to_bytes(ctoken)) video_id = proto.parse(params[2])[2] params = proto.parse(params[6]) params = proto.parse(params[3]) return params[2].decode('ascii'), video_id.decode('ascii')