Giter VIP home page Giter VIP logo

vincechapman / youtube-instrumental-web-store Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4.37 MB

My beat-selling website app. Uses REST APIs: PayPal, Google Drive, Google Docs, YouTube.

Procfile 0.02% Python 95.01% CSS 1.23% HTML 3.09% JavaScript 0.66%
flask flask-application google-docs-api google-drive-api google-drive-api-python google-drive-api-v3 paypal-api paypal-checkout paypal-rest-api python

youtube-instrumental-web-store's People

Contributors

vincechapman avatar

Watchers

 avatar

youtube-instrumental-web-store's Issues

FIX BUG: Project crashes if you try to purchase a beat that doesn’t have the files added

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:

  1. Catch handling, so that even if it can't find the files, it doesn't crash the program.
  2. If statements to check if the files exist before trying to access them.

There's two stages that might be possibly throwing up this error:

  1. The first is when the program tries to access the overall beat folder e.g. 'Metropolitan Tales'
  2. The second is when the program has found the beat folder, and is now trying to access the Stems and Mixdowns folders (it's possible that one might be there and the other one isn't.

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.

Improve zipfile download

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.

Implement SQS queue + EC2 worker environment

Mandatory

  • Add a conditional statement that looks for queue_name in environment variables.
  • Add a flask index path. The SQSD will send a POST request to this every time an item is added to the queue. The POST request will likely contain the ID of the new job
  • Configure code pipeline to deploy the same code to the worker environment as the web environment
  • Create a test function to send through the queue where it will be easy to see whether the job has been received and handled
  • Test whether the pre-configured elastic beanstalk queues work when called by the elastic beanstalk web environment (as so far they don't work when called from my local environment.)
  • Test what happens when a job fails

Optional:

  • Configure auto-scaling

Update fetch videos process to include beat stems and mixdowns

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.

Current location:

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.')

Include inside this function instead:

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()

SSL certificate workaround?

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?

Prevent users from buying unavailable beats

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.

Add live paypal checkout to 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.

Revisit Design (make responsive)

Use a front-end framework to build a sleek, responsive design.

Something like Bulma or Bootstrap.

  • Bootstrap is more comprehensive
  • Bulma is more lightweight

Considerations:

  • What will I actually need for my website?
  • What is the speed difference between the two?
  • Which would be more useful to learn in the long run?

What happens if someone goes back and fills out the lease form again?

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.

Update funnel process

Get people to check if they received the email, which will link them to where they can download the files.

Update beat library to show relevant info

E.g.

  • Whether files are available for instant download
  • Genre of beat (drill, trap, boom bap, RnB, jazz etc.)
  • Mood / style (e.g. ambient, dark, jazzy, hard)

Currently is just showing the same placeholder text for every beat.

Improve system for updating database

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.

Fix lease details form bug

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.

Unified environment variables

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.

Setup Cron schedule

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.