def get_url_jawn(query_string, channel, channel_push_url): url = video.get_url(query_string, channel["page"], channel["pageIndex"]) if url: if channel["pageIndex"] == 8 and url[1] == True: new_page = True else: new_page = False # print url print channel["channel_name"]+" "+str(url[0]) try: if url[1]: google_next = True else: google_next = False channel_push_url(channel["channel_name"], url[0], new_page, google_next) except: return False
def create_channel(channel_name): ch_count = channel_count() channel = { "channel_name": channel_name, "hashtag": getHashtag(channel_name), "query_string": video.build_query_string(channel_name), "urls": ['','','','','','','','','','','','','','','','','','','',''], "created_date": int(round(time.time() * 1000)), "index": ch_count, "video_start": 0, "page": 1, "pageIndex": 0, "latest_tweets": [], "url_timestamps": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] } try: t = int(round(time.time() * 1000)) url = video.get_url(channel["query_string"], 1, 0) if url == False: return False channel["url_timestamps"].pop() channel["url_timestamps"].append(t) channel["urls"].pop() channel["urls"].append(url[0]) channel["video_start"] = t if url[1] == True: channel["pageIndex"] = 1 channel_id = database.channels.insert_one(channel).inserted_id print str(channel_id)+" created" return channel except Exception as e: print e return False sys.stdout.flush()