Exemplo n.º 1
0
from sheet import Sheet
import bitly_api
from dotenv import load_dotenv
import os
import settings
load_dotenv()

access_token = os.getenv("access_token")
c = bitly_api.Connection(access_token = access_token)

table = Sheet("arac-tel","Sheet1")

raw_video_url = table.worksheet.acell(settings.long_url_cell).value
starting_row = table.first_empty_row("shortened-video-url")
end_row = starting_row + 30

for i in range(end_row-starting_row):
	phone_col_number = table.columns.index("phone")+1
	phone = table.worksheet.cell(starting_row+i, phone_col_number).value
	shortened_dict = c.shorten(raw_video_url+"&r="+phone, preferred_domain = "j.mp")
	print(shortened_dict["url"])
	table.update_one_cell(starting_row+i, "shortened-video-url", shortened_dict["url"])