Esempio n. 1
0
def indexView():
    channels = db.find_all_channels()
    mapped_channels = dict()

    for channel in channels:
        mapped_channels[channel["index"]] = {
            "channel_name": channel["channel_name"],
            "hashtag": channel["hashtag"]
        }  

    if not mapped_channels:
        return render_template("error.html", error_message="No Channels Created")

    channel_hashtag = request.args.get('c')

    if channel_hashtag is None:
        random_channel = random.choice(mapped_channels)
        random_channel_hashtag = random_channel["hashtag"]
        return redirect("/?c="+random_channel_hashtag)
    else:
        current_url_index = 0

        current_channel = db.find_channel_by_hashtag(channel_hashtag)

        for i, timestamp in enumerate(current_channel["url_timestamps"]):
            if timestamp == current_channel["video_start"]:
                current_url_index = i 

        # print mapped_channels
        return render_template("index.html", channels=json.dumps(mapped_channels), current_channel=dumps(current_channel), current_url_index=current_url_index)
Esempio n. 2
0
def run():
	try:
		all_channels = db.find_all_channels()
		if all_channels.count() <= 0:
			print "No Channels Exist"
		for channel in all_channels:
			setTweets(channel["channel_name"], channel["hashtag"])
	except Exception as e:
		print e
		sys.stdout.flush()
Esempio n. 3
0
def run():
	try:
		all_channels = db.find_all_channels()
		if all_channels.count() <= 0:
			print "No Channels Exist"
		for channel in all_channels:
			print channel["channel_name"]
			query_string = channel["query_string"]

			url = get_url_jawn(query_string, channel, db.channel_push_url)
			if url == False:
				channel["pageIndex"] += 1
				get_url_jawn(query_string, channel, db.channel_push_url)

	except Exception as e:
		print e
		sys.stdout.flush()
Esempio n. 4
0
    except Exception as e:
        print e
        return jsonify(results=error)

@app.errorhandler(Exception)
def all_exception_handler(error):
    print error
    return render_template("error.html", error_message="Wrong page boi")

@app.route('/static/<path:path>')
def send_static(path):
    return send_from_directory('static', path)

try:
    if db.find_all_channels().count() < 1:
        db.init_channels()
except:
    db.init_channels()

# if __name__ == "__main__":
#     # args = parser.parse_args()
#     # if args.cron:
#     #     def close_handler():
#     #         c.exit()

#     #     atexit.register(close_handler)
#     #     cwd = os.path.dirname(os.path.realpath(__file__))
#     #     c.run(cwd+"/pushURL.py", False)
if __name__ == "__main__":
    socketio.run(app, debug=config.server["debug"], host=config.server["host"], port=config.server["port"])