Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import time
- ids = [1,2,3,4,5,6,7,8,9,10,11,12]
- batch_size = 5
- df = pd.DataFrame()
- def chunks(l, n):
- """Yield successive n-sized chunks from l."""
- for i in range(0, len(l), n):
- yield l[i:i + n]
- for chunk in list(chunks(ids,batchsize):
- items = []
- id_string = ",".join(chunk)
- res = google.youtube().list(id=id_string)
- for r in res:
- data = {}
- data['name'] = res.name
- data['desc'] = res.description
- items.append(data)
- df.append(items,in_place=True)
- time.sleep(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement