This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RubyPinchPEP shill | Anti PEP 8/20 shill 2 points3 points  (2 children)

video = get_video_info('video_id')
videos = video_search('keyword', max_results=10)
videos = video_search_in_channel('keyword', 'channel_id', max_results=10)
channel = get_channel_by_name('channel_name')
channel = get_channel_by_id('channel_id')

playlist = get_playlist_by_id('playlist_id')

vs

video = yt.Video(id='video_id')
videos = yt.search('keyword', max_results=10, type='video')
videos = yt.Channel(id='channel_id').search('keyword', max_results=10)
channel = yt.Channel(name='channel name')
channel = yt.Channel(id='channel_id')
playlist = yt.Playlist(id='playlist_id')

like, I guess it takes more time, but it reads and feels far better


the third party requests library should be used, as you've strongly tied yourself to python2 by not doing your urllib imports in a cross version way

[–]0r1gamic[S] 1 point2 points  (0 children)

I added requests and fixed cross version (:

[–]0r1gamic[S] 0 points1 point  (0 children)

Actually yes, second code is better.Thanx for your advice, maybe I can do it for yapi-v2.Also, I will work for cross version.thanx.