vincechapman / youtube-instrumental-web-store Goto Github PK
View Code? Open in Web Editor NEWMy beat-selling website app. Uses REST APIs: PayPal, Google Drive, Google Docs, YouTube.
My beat-selling website app. Uses REST APIs: PayPal, Google Drive, Google Docs, YouTube.
If the files for the beat aren't in Google drive, the program tries to find them, and obviously can't, which throws up a Key Error.
Possible solutions:
There's two stages that might be possibly throwing up this error:
I have a feeling it's the first point that's causing the issue because I'm pretty sure I dealt with the Stems and Mixdowns stage throwing up issues.
I think this is what I need to use to fix this issue: https://flask.palletsprojects.com/en/2.1.x/patterns/streaming/#basic-usage
@app.route('/large.csv')
def generate_large_csv():
def generate():
for row in iter_all_rows():
yield f"{','.join(row)}\n"
return app.response_class(generate(), mimetype='text/csv')
I'd basically just update current download function so that the return function is an app.response_class
with mimetype='application/zip'
which then call the function that downs the file fetching and zipping. Or something along those lines basically.
Once lease details have been collected, update the paypal order to include these - so the artist's name will be attached to the transaction.
Right now I think the request has to do too many things and so heroku timesout. Maybe use redirects, to different pages to stop it from timing out.
Don't forget to change this to use the email in the paypal order.
Beat stems and Beat mixdowns should be checked for and added to model as part of the adding videos to database process.
Right now this is happening in some other stage, which I don't think really makes sense.
EDIT: Currently these details are only being added when the update_database()
function runs. This function calls add_uploads_to_database()
anyway, so will add this code to add_uploads_to_database()
for consistency.
app.py
@app.route('/fetchvideos', methods=['GET', 'POST'])
def update_database():
if request.method == 'POST':
clear_database()
add_uploads_to_database()
beat_folder_id = return_directory(start_folder_id)
for i in dict.keys(beat_folder_id):
if 'Mixdown' in return_directory(beat_folder_id[i]):
try:
video = Videos.query.filter_by(video_beat_name=i).first()
video.beat_mixdowns = return_directory(beat_folder_id[i])['Mixdown']
db.session.commit()
except:
db.session.rollback()
print('Error 1: Video not in database. Or other error.')
if 'Stems' in return_directory(beat_folder_id[i]):
try:
video = Videos.query.filter_by(video_beat_name=i).first()
video.beat_stems = return_directory(beat_folder_id[i])['Stems']
db.session.commit()
except:
db.session.rollback()
print('Error 2: Video not in database. Or other error.')
youtube.py
def add_uploads_to_database():
video_id_list = fetch_upload_ids()
keep_looping = True
while keep_looping:
if len(video_id_list) < 50:
request = youtube.videos().list(
part="snippet,contentDetails",
id=video_id_list[0:len(video_id_list)]
)
keep_looping = False
else:
request = youtube.videos().list(
part="snippet,contentDetails",
id=video_id_list[0:50]
)
video_id_list = video_id_list[50:]
try:
response = request.execute()
except HTTPError as e:
print('Error response status code : {0}, reason : {1}'.format(e.status_code, e.error_details))
# This takes those details and adds them to our database.
for video in response['items']:
video_to_add = Videos(
video_id = video['id'],
video_title = video['snippet']['title'],
video_publishedAt = video['snippet']['publishedAt'],
video_thumbnail = video['snippet']['thumbnails']['medium']['url'],
video_description = video['snippet']['description'],
video_beat_name = process_description(video['snippet']['description'], 'Beat name'),
video_tags = process_description(video['snippet']['description'], 'Tags'),
audio_url = get_audio_url(video['id'])
)
db.session.add(video_to_add)
db.session.commit()
Something like Google Analytics, to determine how people are engaging with my website
Currently if you just enter vincemaina.herokuapp.com
it takes you to the unsecure link. But if you enter 'https://vincemaina.herokuapp.com/` it takes you to the secure link (with the padlock and everything.)
I might be able to get out of buying my own SSL certificate by just redirecting users to the secure version. Something like this maybe:
if request.url == 'http://vincemaina.herokuapp.com/':
return redirect ('https://vincemaina.herokuapp.com/')
Do I need to do this on every page i.e. every route?
Allow users to play beats directly from the page listing all the beats.
Some relevant resources:
On the off-chance someone has purchased the beat-exclusively, or I have reserved the beat for someone, I should prevent people from being able to buy these beats on my website.
For this I'd need to include beat availability as an attribute in Video model in my database.
Guide on creating draggable seekbars: https://stackoverflow.com/questions/59544183/slider-seekbar-drag-function-for-the-audio-player-on-website
Maybe use the sandbox client_id and client_secret within my local environment. And then in the heroku environment use the live client_id and client_secret.
Probably best the live ones on heroku once I'm done with testing.
Use a front-end framework to build a sleek, responsive design.
Something like Bulma or Bootstrap.
Considerations:
I believe if someone went back and filled out the lease form again it'd create a new lease document in google drive and then throw an error because it's trying to capture the order again.
Placing the create_lease function after capture order would fix this, because then if someone went back and tried to fill out the form again, the capture_order request would throw an error before the create_lease function has had a chance to run.
Something along these lines:
Genre: Drill
or
Genre: Drill | Garage | Afrobeat
Get people to check if they received the email, which will link them to where they can download the files.
E.g.
Currently is just showing the same placeholder text for every beat.
Email being sent every time the receipt page is loaded, instead of just once.
Move the send email to a different part of the checkout process. Maybe after capture order but within the same function.
Currently the database is cleared first and then filled out again with the most recent data. This process takes the better part of a minute.
Ensure there is no downtime when someone tries to access the website while the database is updating.
Currently if I enter twice on the lease details form, it causes the program to crash as we are attempting to capture the order twice. Update this so that only the first click/enter registers.
Not a pressing issue, but currently I have a separate set of environment variables for my worker environment and my web environment. They're both exactly the same.
Would be nice to have both/all environment referring to a single set of environment variables so i don't have to remember to manually update every single one.
Specify that the time is given in GMT on the lease.
Schedule function to check APIs for every single video every 15 mins. If any details have changed, set up background job to update all fields
Schedule function to check it video audio links still work
Keep redis empty as much as possible
Avoid making unnecessary calls to RDS (if I decide to implement that for database)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.