def channel(channelId): try: order = request.args.get('order', 'date') options = { 'part': 'snippet', 'order': order, 'key': 'AIzaSyDkNYRbreB8JHOggvjSznMIuw6TlvkHjGQ', 'regionCode': Repo.getRegion()['countryCode'], 'channelId': channelId, 'type': 'video', 'maxResults': 50 } channel = YouTube.getChannel(channelId) if channel['status'] == True: search = YouTube.search(options) return render( 'channel', search=search, channel=channel, order=order) if search['status'] == True else render( 'error', code=404, message=search['message']) else: return render('error', code=400, message=channel['message']) except Exception as e: return render('error', code=500, message=str(e))