Giter Club home page Giter Club logo

anitab-org / stem-diverse-tv Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 49.0 2.51 MB

STEM Diverse TV is a project which gather and provide inspiring, motivating, informative, educational and supportive videos about diversity in STEM. This is a backend which provide content for multiple frontend applications build with Applicaster Zapp platform.

Home Page: https://stem-diverse-tv.herokuapp.com/

License: GNU General Public License v3.0

Python 83.40% HTML 7.51% Dockerfile 0.65% Makefile 0.38% JavaScript 6.29% CSS 1.73% Procfile 0.04%
backend flask hacktoberfest python3

stem-diverse-tv's People

Contributors

aaishpra avatar aayush-hub avatar allcontributors[bot] avatar anjali1102 avatar anna4j avatar annabauza avatar anshsrtv avatar aparnaabraham avatar biospherexr avatar dependabot[bot] avatar epicadk avatar harshkumarchoudary avatar isabelcosta avatar j-raghav avatar jaivanti avatar jalajcodes avatar lem0n4id avatar nandini45 avatar nenadpantelic avatar poobalan1210 avatar rahulm2310 avatar s4-2 avatar vatsalkul avatar vj-codes avatar znamazbayeva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stem-diverse-tv's Issues

feat: DELETE existing category endpoint

Is your feature request related to a problem? Please describe.

In our CMS we want to remove existing category

Describe the solution you'd like

DELETE should be authenticated

Additional context

If category has existing connections in other tables those records should also be removed
Return success or fail

feat: add authentication endpoint

Is your feature request related to a problem? Please describe.

only authorised and authenticated users can make changes to database

Describe the solution you'd like

create signup and login endpoints do users can received access_tokens for making changes in database

Bug: Endpoint to add youtube video returns an error

Describe the bug

/videos/youtube endpoint returns 500 Internal server error

To Reproduce

Steps to reproduce the behavior:

  1. Start the server.
  2. Go to http://localhost:500
  3. Scroll down to video/youtube endpoint
  4. Fill in the required details and make the request.
  5. See error.

Expected behavior

The endpoint should create a new video.

Screenshots

image

Desktop (please complete the following information):

  • OS: any
  • Browser any
  • Version any

Smartphone (please complete the following information):

  • Device: any
  • OS: any
  • Browser any
  • Version any

Additional context

Check the terminal to find out the cause of the error.

docs: update readme and how to setup the project

Describe the feature

As a developer,
I need to know what the repository is about so that I know more about the project and run it locally as well as contribute.

Acceptance Criteria

Update [Required]
Content about what the repository is and how to set it up

Definition of Done

All of the required items are completed.
Approval by 1 mentor.

Expected behavior

the readme is updated with various details.

Estimation

1 hour

Feat: GET all categories endpoint

Is your feature request related to a problem? Please describe.

We can not list all categories on our CMS

Solution

Add GET all categories endpoint - authentication required

feat: Implement Authorisation functionality

Is your feature request related to a problem? Please describe.

As of now anyone can access our backend features. But this is originally intended to work for only authorised users.
We need to implement authorisation functionality.

Describe the solution you'd like

Authentication is already implemented, we have used firebase email signing. Now, we need to make our backend talk to firebase.
Frontend will gives us the auth token and after getting a request from frontend, our backend check if the token is legitimate by using firebase auth.verify_id_token(token_header) function.
If the user is legitimate, our backend will provide the information requested from frontend.

Describe alternatives you've considered

Alternatively, we can implement custom jet authorisation, but firebase will made our work easy.

Additional context

We can make a view decorator in python and use that using this syntax (@token_required) above the api endpoints.

feat: Create add section POST endpoint

Is your feature request related to a problem? Please describe.

We have no endpoint to add section to db at the moment

Describe the solution you'd like:

post following JSON structure:

{
  title:"section title",
  category: "category title",
}

so it can be added to the database.

If section with that title for this category already exists then endpoint should return error.

if category with that title does not exists it should add one, otherwise it should use existing one.

The proper relation should be saved in CATEGORY_SECTION table.

Additional context:

User need to be authorised(logged in) with access_token

feat: Configure CORS headers

Is your feature request related to a problem? Please describe.

We need CORS setup to enable the communication between API and CMS.

Describe the solution you'd like

Define the list of allowed origins. The port of the origin should be 3000, we will probably use the default React port.

Describe alternatives you've considered

For the initial phase, we could allow all origins, but we need to change that when we upgrade to the production level (for security purposes).

Additional context

N/A

feat: DELETE section endpoint

Is your feature request related to a problem? Please describe.

In our CMS we want to remove existing section

Describe the solution you'd like

DELETE should be authenticated

Additional context

If section has existing connections in other tables those records should also be removed
Return success or fail

Feat: Add regular videos to the feed

Is your feature request related to a problem? Please describe.

At the moment, the feed doesn't apply to the regular, non-YT videos. We need to adapt the existing code, so we append regular videos to feed also.

Describe the solution you'd like

Add regular videos to the feed too. Instead of the stream URL, pass their native URL.

Describe alternatives you've considered

N/A

Additional context

N/A

Bug: Update README with the additional instructions for the firebase setup

Describe the bug

In the README, for the Firebase integration, these instructions are provided:

  • Please download Firebase Admin SDK service json file from Firebase Console and put that in project's root directory. Rename file to firebase_cred.json
  • Make .env file from given .env.template file and add details like API_KEY, which is a web api key from firebase. Find your project's web api key in project's overview tab on firebase console.

The code demands a file with the name google-credentials, not the firebase_cred.json. Also, I would add a more detailed instruction on creating and download the Firebase credentials file (from the Firebase console), for those who're not so familiar with Firebase. In general, we need to change the code (rename Firebase auth file) - that can be another issue and README with the instructions - this issue.

To Reproduce

Steps to reproduce the behavior:

  1. Go to README.md and check Firebase integration part
  2. firebase credentials file is misspelled as firebase_cred.json instead of google-credentials.json
  3. Also, the same thing should be fixed in the .gitignore -> replace firebase_cred.json with google-credentials.json

Expected behavior

Replace firebase_cred.json with google-credentials.json in the README and .gitignore. Also, add more details description on setting the firebase credentials auth - instructions on how to create an API key and download it.

Screenshots

image

Desktop (please complete the following information):

  • OS: [any]
  • Browser [any]
  • Version [any]

Smartphone (please complete the following information):

  • Device: [any]
  • OS: [any]
  • Browser [any]
  • Version [any]

Create endpoint that stream mp4 from youtube video

Description

As a user
I need stream creative commons youtube videos to mp4 video,
so that I can watch videos on any platform.

Mocks

I have updated this script to python3 and was able to stream youtube video as mp4. Below is updated script to python 3.

from wsgiref.simple_server import make_server
import os
import urllib
import youtube_dl


def youtube_dl_extract_info(video_id):
    ydl = youtube_dl.YoutubeDL()

    full_video_url = "%s%s" % ("https://www.youtube.com/watch?v=", video_id)

    with ydl:
        result = ydl.extract_info(
            full_video_url,
            download=False
        )
    return result


def youtube_dl_extract(video_id, formats_ids):
    formats_ids_arr = formats_ids.split(',') if formats_ids else None
    info = youtube_dl_extract_info(video_id)
    #print "\n".join(["%s, %s, %s" % (i['format'].encode("utf-8"), i['ext'],  i['abr'] if 'abr' in i else '') for i in info['formats']])
    return next((y['url'] for x in formats_ids_arr for y in info['formats'] if x in y['format'])) if formats_ids else info['formats'][0]['url']



def stream_media(media_url, start_response):
    req = urllib.request.Request(media_url, headers={'User-Agent': "Magic Browser"})
    u = urllib.request.urlopen(req)
    meta = u.info()
    u.headers['Content-Length']
    file_size = int(u.headers['Content-Length'])
    file_size_dl = 0
    block_sz = 8192
    mp3file = urllib.request.urlopen(media_url)

    headers = [('Content-type', 'audio/mp4'), ('Content-length', str(file_size)), ('Accept-Ranges', 'bytes')]
    write = start_response('200 OK', headers)

    while True:
        chuck = mp3file.read(block_sz)
        if not chuck:
            print("break %s".format(file_size_dl))
            break
        yield chuck


def hello_world_app(environ, start_response):
    print(environ['QUERY_STRING'])
    params = urllib.parse.parse_qs(environ['QUERY_STRING'])
    video_id = params.get('id', [False])[0]
    formats = params.get('formats', [False])[0]

    if(not video_id):
        headers = [('Content-type', 'text/html')]
        start_response('200 OK', headers)
        return ['youtube-dl heroku <a href="https://github.com/kobiburnley/youtube-dl/blob/heroku/README.md">read me</a>']

    # get media by type & quality
    # type = params.get('type', [False])[0]
    # quality = params.get('quality', [False])[0]
    try:
        media_url = youtube_dl_extract(video_id, formats)
        return stream_media(media_url, start_response)
    except:
        headers = [('Content-type', 'text/html')]
        start_response('200 OK', headers)
        return ['An error occurred.']


port = os.environ.get("PORT", "5000")
httpd = make_server('', int(port), hello_world_app)
print("Serving HTTP on port " + port + "...")

httpd.serve_forever()

Endpoint should take youtube video id as argument and return stream by selected format:

249 - audio only (DASH audio), webm, 50
250 - audio only (DASH audio), webm, 70
171 - audio only (DASH audio), webm, 128
140 - audio only (DASH audio), m4a, 128
251 - audio only (DASH audio), webm, 160
141 - audio only (DASH audio), m4a, 256
278 - 256x144 (DASH video), webm,
160 - 256x144 (DASH video), mp4,
242 - 426x240 (DASH video), webm,
133 - 426x240 (DASH video), mp4,
243 - 640x360 (DASH video), webm,
134 - 640x360 (DASH video), mp4,
244 - 854x480 (DASH video), webm,
135 - 854x480 (DASH video), mp4,
247 - 1280x720 (DASH video), webm,
136 - 1280x720 (DASH video), mp4,
248 - 1920x1080 (DASH video), webm,
137 - 1920x1080 (DASH video), mp4,
17 - 176x144 (small), 3gp,
36 - 320x240 (small), 3gp,
5 - 400x240 (small), flv,
43 - 640x360 (medium), webm,
18 - 640x360 (medium), mp4,
22 - 1280x720 (hd720), mp4,

Acceptance Criteria

Update [Required]

  • make sure endpoint required access token - we don't want people to use our backend to stream mp4

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

5 hours

Feat: create POST section and video connection

Is your feature request related to a problem? Please describe.

in our CMS we want to add existing video to section

Describe the solution you'd like

  • POST should be authenticated
  • required existing video id
  • required existing section id

Additional context

Return success or fail

feat: create endpoint which takes section id and return JSON feed

Description

As a developer,
I need to create an endpoint which takes section and return JSON feed,
so that I can access the relevant information.

Endpoint should look like:

/feed/section/{section_id}

{
  "type": { "value": "feed" },
  "id": "section_id",
  "title": "section_title",
  "media_group": [],
  "entry": [  // list of videos in following format
    {
      "author": { "name": "author name" },
      "type": { "value": "video" },
      "id": "video id",
      "title": "video title",
      "summary": "video summary",
      "published": "2005-04-06T20:25:05-08:00",
      "updated": "2005-04-06T20:25:05-08:00",
      "content": {
        "src": "url to video wrapped with mp4 converter",
        "type": "video/hls"
      },
      "link": { "type": "link", "href": "" },
      "media_group": [
        {
          "type": "image",
          "media_item": [
            {
              "key": "image_base",
              "src": "preview image url",
              "type": "extern_image"
            }
          ]
        }
      ],
      "extensions": { "section": "None" }
    }
  ]
}

Additional context:

Require implemented issue #50 to complete mp4 wrapper link
please note if video is youtube it should return a stream of format 22 - mp4

Acceptance Criteria

Update [Required]

  • Endpoint is created

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

3 hours

bug: remove details from /video/youtube payload

Describe the bug

youtube payload takes too much in payload. We should be able to edit freshly created youtube. This will require bunch of updates.

Remove this from payload:

"sections": [
    {
      "title": "string",
      "category": "string",
      "id": "string"
    }
  ],
  "authors": [
    0
  ]

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://stem-diverse-tv.herokuapp.com/
  2. Click on /video/youtube payload
  3. See payload takes too many arguments

Expected behavior

Payload should only take youtube argument

Screenshots

Screenshot 2021-02-03 at 18 53 54

Desktop (please complete the following information):

  • OS: Any
  • Browser: Any
  • Version: Any

Smartphone (please complete the following information):

  • Device: Any
  • OS: Any
  • Browser: Any
  • Version: Any

feat: add endpoint GET all videos by author id or author name

Is your feature request related to a problem? Please describe.

author id or author name should be url parameter.

Describe the solution you'd like:

get should return videos by specific author in expected json structure

Get list of all authors in following json structure:

{
  "type": {
    "value": "feed"
  },
  "author": {
    "name": "author name"
  },
  "id": "NSB-03",
  "title": "LATEST",
  "media_group": [],
  "entry": [
    {
      "author": {
        "name": "SAS Software"
      },
      "type": {
        "value": "video"
      },
      "id": "NSBT-0001",
      "title": "STEM Career Showcase for Students with Disabilities 2017",
      "summary": "Students with disabilities meet and learn from successful STEM role models with similar disabilities at the North Carolina Museum of Natural Sciences.",
      "published": "2005-04-06T20:25:05-08:00",
      "updated": "2005-04-06T20:25:05-08:00",
      "content": {
        "src": "https://www.youtube.com/watch?v=AsAvCVAiqJo",
        "type": "video/hls"
      },
      "link": {
        "type": "link",
        "href": ""
      },
      "media_group": [
        {
          "type": "image",
          "media_item": [
            {
              "key": "image_base",
              "src": "http://i3.ytimg.com/vi/AsAvCVAiqJo/maxresdefault.jpg",
              "type": "extern_image"
            }
          ]
        }
      ],
      "extensions": {}
    }
  ]
}

feat: add GET all authors endpoint

Is your feature request related to a problem? Please describe.

We do not have endpoint which list all available authors

Describe the solution you'd like:

Get list of all authors in following json structure:
{
 authors: [
 {
   id:"author Id", 
   name: "author name"
 }]
}

feat: Create add author POST endpoint

Is your feature request related to a problem? Please describe.

We have no endpoint to add author to db at the moment

Describe the solution you'd like:

post following JSON structure:

{
  name:"author_name",
  profile_image: "profile_image_url" or null,
}

so it can be added to the database.

If author with that name already exists then endpoint should return error.

Describe alternatives you've considered

Alternatively if user with this name exists it can return that user data.

Additional context

Consider how to add second author with the same name.

Send verify link to user's email address.

Is your feature request related to a problem? Please describe.

When we register a new user, the verify link is returned in the response, which is not a good thing.
In order to verify user, our system needs to send the verification link to user's registered email address.

Describe the solution you'd like

To be able to send an email we can use third party services like mailgun but using gmail SMTP would be preferred.

  1. Implement gmail SMPT service.
  2. Send verification link to user's email address.
  3. Remove verification link from response body.
  4. Make sure to add email and password as an environmental variables.

Additional context

NOTE: Make sure you turned on two factor authentication as Gmail uses it, in order to work in third party applications.

Create the config.yml file for the Welcome Bot

Description

As a first time contributor,
I need a bot to help guide my first contribution,
so that I can follow this org's contribution guidelines.

Mocks

Screen Shot 2020-08-06 at 10 26 14 AM

Acceptance Criteria

Update [Required]

  • newIssueWelcomeComment is complete with the correct links to this repo.
  • newPRWelcomeComment is complete with the links to the project's stream or topic and the repo's Code of Conduct.
  • firstPRMergeComment is complete.

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

0.5 hours

feat: Add edit category endpoint

Is your feature request related to a problem? Please describe.

I want to have ability to change the category title

Describe the solution you'd like

PATCH endpoint sending new title for given id

Describe alternatives you've considered

PUT endpoint.

Code cleanup: Clean the codebase and setup the code convention

What to do: make some changes (polishing ones) to the existing codebase:
1.remove unused imports
2. format the code (by PEP8 convention)
3. restructure files:

  • controllers (for API endpoints)
  • validations
  • DAO
  • model
  • service (for more complex business logic)
  • mappers
  • ....
  1. make a standard for endpoint URLs. By RESTful concept, for resources, plurals should be used: e.g. users, videos etc.

It is much easier to do this at the very beginning of the project - better for consistency and will prevent some code refactoring in the future. It would make the code more clean and concise.

feat: Create add YouTube video POST endpoint

Is your feature request related to a problem? Please describe.

We have no endpoint to add section to db at the moment

Describe the solution you'd like:

post following JSON structure:

{
  "url": "YouTube video url",
  "sections": [
    {
      "title": "section title",
      "category": "category title"
    },
    {
      "id": "existing section id"
    }
  ],
  "authors": [
    {
      "name": "author name"
    },
    {
      "id": "existing author id"
    }
  ]
}

so it can be added to the database.

This endpoint should use YouTube API to fetch all informations about video. YouTube API token should be added to environment variables.

Above json should update following tables:

  • add video record if it does not exists (determinate by url), if it exist it should update existing relation,
  • if author name does not exists it should be created and relation to video should be created,
  • if section title for category does not exists it should be created and relation to video and or section-category should be created,
  • if category title does not exists it should be created and relation to video and section-category should be created,

Authors and sections-category can be determinate by unique data or identifiers.

Additional context:

User need to be authorised(logged in) with access_token

Bug: Database constraints/indexes and data validations are missing

Describe the bug

I think we need some database constraints (unique, not null) and indexes for some fields. That's the reason we have some bugs in our use-cases: multiple categories with the same name, users with the same username/email. This should be combined with the POST/PUT data validations.

To Reproduce

Steps to reproduce the behavior:

  1. Go to Postman/Swagger UI
  2. create a category with the title that was used before - POST categories
  3. that shouldn't be allowed
    That's just one example, we have multiple bugs of this type.

Expected behavior

Add unique constraints for identifying columns in all tables, Add not null constraints, validations for emails....Also, add indexes for the field we expect to be searched extensively. (think about this, do we need it)

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

Add any other context about the problem here.

Add filter by video type to get videos endpoint

Is your feature request related to a problem? Please describe.

Out of 8 platforms only 1 at the moment supports youtube videos. We should be allowed to filter videos by supported formats.

Describe the solution you'd like

The endpoint should take either include or exclude parameter in url and return only list of videos which satisfy filtered types.

Describe alternatives you've considered

Provide youtube plugin to all 8 platforms which is impossible atm. Due to youtube API limitation (no support on TV platforms).

feat: add users table to database

Is your feature request related to a problem? Please describe.

We need to make sure unauthorised people can not change our database.

Describe the solution you'd like

Add User table which contains:

USERS TABLE

Key Type
id INTEGER
name VARCHAR(30)
username VARCHAR(30)
email VARCHAR(30)
password_hash VARCHAR(100)
registration_date FLOAT
terms_and_conditions_checked BOOLEAN
access_rights INT
is_email_verified BOOLEAN
email_verification_date DATETIME

User Rights are sum of integers depending on level of access.

Value Table access rights
1 VIDEO_READ
2 VIDEO_WRITE
4 AUTHOR_READ
8 AUTHOR_WRITE
16 VIDEO_AUTHOR_READ
32 VIDEO_AUTHOR_WRITE
64 SECTION_READ
128 SECTION_WRITE
512 CATEGORY_READ
1024 CATEGORY_WRITE
2048 SECTION_VIDEO_READ
4096 SECTION_VIDEO_WRITE
8192 CATEGORY_SECTION_READ
16384 CATEGORY_SECTION_WRITE
32768 USERS_READ
65536 USERS_WRITE

So Admin with all right will have 131โ€‰071

chore: fix deploy on Heroku

Issue

App Is not deploying on Heroku as we have not uploaded google credentials json file.
To solve this we need to add buildpack which can make use of google credential json file in the cloud without having to push it in our repository.

feat: Create add category POST endpoint

Is your feature request related to a problem? Please describe.

We have no endpoint to add category to db at the moment

Describe the solution you'd like:

post following JSON structure:

{
  title:"title",
}

so it can be added to the database.

If category with that title already exists then endpoint should return error.

Additional context:

User need to be authorised(logged in) with access_token

docs: Create Issue Templates

Describe the bug/feature

As a developer,
I need to see the issue templates preloaded on clicking new issue,
so that I can use those templates to create issues.

Acceptance Criteria

Update [Required]

Created Issue Templates for

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Expected behavior

  • On creating a new issue, the issue template should get preloaded.

Estimation

1 hour

docs: Update documentation with the details about enabling YT API

Is your feature request related to a problem? Please describe.

For using YT API (we need it to get the details about the YT video in the /videos/youtube endpoint) we need to enable it in the Google Cloud console. Otherwise, the YT API will give the permission error. I think we need to add it to the README.

Describe the solution you'd like

Add a note about the YT API enabling to the README with the instructions on how to do that

Describe alternatives you've considered

N/A

Additional context

N/A

docs: Add description to video stream converter

Describe the bug

Swagger should explain what are acceptable formats for stream converter
Endpoint should take youtube video id as argument and return stream by selected format:

To Reproduce

Steps to reproduce the behaviour:

  1. Go to https://stem-diverse-tv.herokuapp.com/
  2. Click on GET /videos/stream/{videoId}/{format}
  3. See there is no description about available formats

Expected behaviour

Show available formats as below

249 - audio only (DASH audio), webm, 50
250 - audio only (DASH audio), webm, 70
171 - audio only (DASH audio), webm, 128
140 - audio only (DASH audio), m4a, 128
251 - audio only (DASH audio), webm, 160
141 - audio only (DASH audio), m4a, 256
278 - 256x144 (DASH video), webm,
160 - 256x144 (DASH video), mp4,
242 - 426x240 (DASH video), webm,
133 - 426x240 (DASH video), mp4,
243 - 640x360 (DASH video), webm,
134 - 640x360 (DASH video), mp4,
244 - 854x480 (DASH video), webm,
135 - 854x480 (DASH video), mp4,
247 - 1280x720 (DASH video), webm,
136 - 1280x720 (DASH video), mp4,
248 - 1920x1080 (DASH video), webm,
137 - 1920x1080 (DASH video), mp4,
17 - 176x144 (small), 3gp,
36 - 320x240 (small), 3gp,
5 - 400x240 (small), flv,
43 - 640x360 (medium), webm,
18 - 640x360 (medium), mp4,
22 - 1280x720 (hd720), mp4,

Screenshots

Screenshot 2021-02-12 at 22 29 24

Desktop (please complete the following information):

  • OS: Any
  • Browser: Any
  • Version: Any

Smartphone (please complete the following information):

  • Device: Any
  • OS: Any
  • Browser: Any
  • Version: Any

feat: Create add video POST endpoint

Is your feature request related to a problem? Please describe.

We have no endpoint to add section to db at the moment

Describe the solution you'd like:

post following JSON structure:

{
  "url": "video url",
  "title": "title",
  "preview": "title",
  "published": "published",
  "source": "YouTube", // unless different
  "channel": "channel title",
  "duration": duration_in_seconds,
  "archived": true or false,
  "free_to_reuse": true or false,
  "authorised_to_reuse": true or false,
  "sections": [
    {
      "title": "section title",
      "category": "category title"
    },
    {
      "id": "existing section id"
    }
  ],
  "authors": [
    {
      "name": "author name"
    },
    {
      "id": "existing author id"
    }
  ]
}

so it can be added to the database.

Above json should update following tables:

  • add video record if it does not exists (determinate by url), if it exist it should update existing relation,
  • if author name does not exists it should be created and relation to video should be created,
  • if section title for category does not exists it should be created and relation to video and or section-category should be created,
  • if category title does not exists it should be created and relation to video and section-category should be created,

Authors and sections-category can be determinate by unique data or identifiers.

Additional context:

User need to be authorised(logged in) with access_token

As a developer, I need database, so that I can hold videos links and metadata.

Description

As a developer,
I need database,
so that I can hold videos links and metadata.

Acceptance Criteria

VIDEOS TABLE

Key Type
ID unique id
URL string
TITLE string
PUBLISHED int(date)
SOURCE string
CHANNEL string
DURATION int
ARCHIVED bool
FREE_TO_REUSE bool
AUTHORISED_TO_REUSE bool

AUTHOR TABLE

Key Type
ID unique id
NAME string
PROFILE_IMAGE string

VIDEO_AUTHOR TABLE

Key Type
ID unique id
VIDEO_ID string
AUTHOR_ID string

SECTION TABLE

Key Type
ID unique id
TITLE string

CATEGORY TABLE

Key Type
ID unique id
TITLE string

SECTION_VIDEO TABLE

Key Type
ID unique id
SECTION_ID string
VIDEO_ID string

CATEGORY_SECTION TABLE

Key Type
ID unique id
CATEGORY_ID string
SECTION_ID string

Update [Required]

  • [VIDEOS TABLE]
  • [AUTHOR TABLE]
  • [VIDEO_AUTHOR TABLE]
  • [SECTION TABLE]
  • [CATEGORY TABLE]
  • [SECTION_VIDEO TABLE]
  • [CATEGORY_SECTION TABLE]

Enhancement to Update [Optional]

  • [Update documentations regarding database changes]

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

[8] hours

feat: Add edit section endpoint

Is your feature request related to a problem? Please describe.

I want to have ability to change the section title

Describe the solution you'd like

PATCH endpoint sending new title for given id

Describe alternatives you've considered

PUT endpoint.

bug: move /sections/category/{id} to category/{id}/section

Describe the bug:

hierarchy for our data structure is:
Categories contains sections, sections contains videos.
move /sections/category/{id} to category/{id}/section

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://stem-diverse-tv.herokuapp.com/
  2. Click on /sections/category/{id}
  3. See error this should be under category rather then section

Expected behavior

url should be category

Screenshots

Screenshot 2021-02-03 at 19 02 02

Desktop (please complete the following information):

  • OS: Any
  • Browser: Any
  • Version: Any

Smartphone (please complete the following information):

  • Device: Any
  • OS: Any
  • Browser: Any
  • Version: Any

Feat: Add GET all sections endpoint for given category id

Is your feature request related to a problem? Please describe.

In our CMS we want to list all sections for selected category

Describe the solution you'd like

Add GET all sections endpoint for given category id

Additional context

endpoint path format: /categories/{id}/sections
Endpoint returns all sections for given category with titles and identifiers

Research if we can stream youtube to mp4 video format

Description

As a user
I need stream creative comons youtube videos to mp4,
so that I can watch videos on any platform.

Mocks

I have updated this script to python3 and was able to hear audio, if we could stream youtube to mp4 videos then we would be able to prepare content for creative commons license and support multiple devices!!!

from wsgiref.simple_server import make_server
import os
import urllib
import youtube_dl


def youtube_dl_extract_info(video_id):
    ydl = youtube_dl.YoutubeDL()

    full_video_url = "%s%s" % ("https://www.youtube.com/watch?v=", video_id)

    with ydl:
        result = ydl.extract_info(
            full_video_url,
            download=False
        )
    return result


def youtube_dl_extract(video_id, formats_ids):
    formats_ids_arr = formats_ids.split(',') if formats_ids else None
    info = youtube_dl_extract_info(video_id)
    #print "\n".join(["%s, %s, %s" % (i['format'].encode("utf-8"), i['ext'],  i['abr'] if 'abr' in i else '') for i in info['formats']])
    return next((y['url'] for x in formats_ids_arr for y in info['formats'] if x in y['format'])) if formats_ids else info['formats'][0]['url']



def stream_media(media_url, start_response):
    req = urllib.request.Request(media_url, headers={'User-Agent': "Magic Browser"})
    u = urllib.request.urlopen(req)
    meta = u.info()
    u.headers['Content-Length']
    file_size = int(u.headers['Content-Length'])
    file_size_dl = 0
    block_sz = 8192
    mp3file = urllib.request.urlopen(media_url)

    headers = [('Content-type', 'audio/mp4'), ('Content-length', str(file_size)), ('Accept-Ranges', 'bytes')]
    write = start_response('200 OK', headers)

    while True:
        chuck = mp3file.read(block_sz)
        if not chuck:
            print("break %s".format(file_size_dl))
            break
        yield chuck


def hello_world_app(environ, start_response):
    print(environ['QUERY_STRING'])
    params = urllib.parse.parse_qs(environ['QUERY_STRING'])
    video_id = params.get('id', [False])[0]
    formats = params.get('formats', [False])[0]

    if(not video_id):
        headers = [('Content-type', 'text/html')]
        start_response('200 OK', headers)
        return ['youtube-dl heroku <a href="https://github.com/kobiburnley/youtube-dl/blob/heroku/README.md">read me</a>']

    # get media by type & quality
    # type = params.get('type', [False])[0]
    # quality = params.get('quality', [False])[0]
    try:
        media_url = youtube_dl_extract(video_id, formats)
        return stream_media(media_url, start_response)
    except:
        headers = [('Content-type', 'text/html')]
        start_response('200 OK', headers)
        return ['An error occurred.']


port = os.environ.get("PORT", "5000")
httpd = make_server('', int(port), hello_world_app)
print("Serving HTTP on port " + port + "...")

httpd.serve_forever()

Acceptance Criteria

Update [Required]

  • research if we can stream youtube to mp4 on our server side

Enhancement to Update [Optional]

  • if yes then create a ticket with all necccessary informations so we could start using creative commons youtube videos to develop all 8 client platforms

Definition of Done

  • All of the required items are completed.
  • Approval by 1 mentor.

Estimation

3 hours

Feat: POST section, category connection

Is your feature request related to a problem? Please describe.

Create a post endpoint to add section category connection

Describe the solution you'd like

I want to be able to create multiple connections between categories and sections

Fix: move /video/add_category to /category endpoint

Describe the bug

Move Add Category from video endpoint to category just like section endpoint

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://stem-diverse-tv.herokuapp.com/
  2. Click on Video
  3. Scroll down to Add category
  4. See category should not be under video endpoint structure

Expected behavior

Post Category should be separate from video

Screenshots

Screenshot 2021-01-31 at 12 54 23

Desktop (please complete the following information):

  • OS: Any
  • Browser: Any
  • Version: Any

Smartphone (please complete the following information):

  • Device: Any
  • OS:Any
  • Browser: Any
  • Version: Any

Bug:Multiple user can be created using same email id

Describe the bug

A clear and concise description of what the bug is.
Currently when a user tries to register to stem-diverse .It only searches for user with username not with email .A user can create multiple account with same email id but with different username each time .You might get error while creating the user with same email id in firebase .but if you switch to any other database then you need to check the request in the backend whether the user with that email id exists or not

To Reproduce

Steps to reproduce the behavior:

  1. Go to stem-diverse-cms
  2. Click on register tab
  3. Try to register with a email. & verify it . Again use that same email to register . new user will be created.

Expected behavior

A user must not be able to create multiple accounts with same email id.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Browser Firefox

feat: Create search author by name endpoint

Is your feature request related to a problem? Please describe.

Create search author by id endpoint.

Describe the solution you'd like

As a developer I want to put search query as parameter of the endpoint and receive authors array in JSON structure:

{
  authors: [
  {
    id:"author_id",
    name:"author_name",
    profile_image: "profile_image_url" or null,
  }]
}

Additional context

if there are no result I want to receive empty array in following JSON structure:

{
  authors: []
}

Feat: create DELETE section and video connection endpoint

Is your feature request related to a problem? Please describe.

In our CMS we want to remove existing existing connection between section and video

Describe the solution you'd like

DELETE should be authenticated

Additional context

Return success or fail

Get latest videos should not require authentication token

Describe the bug

Our STEM diverse have multiple client apps:

  1. CMS which require authentication for each configuration (addin/edditing) endpoint
  2. Mobile and TV Client apps - which read configured data unrestricted

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://stem-diverse-tv.herokuapp.com/
  2. Click on GET /video/latest
  3. Click on Try it
  4. See endpoint requires authentication

Expected behavior

Getting content in applicaster format should be free from authentication

Screenshots

Screenshot 2021-01-30 at 22 20 31

Desktop (please complete the following information):

  • OS: Any
  • Browser: Any
  • Version: Any

Smartphone (please complete the following information):

  • Device: Any
  • OS:Any
  • Browser: Any
  • Version: Any

Additional context

If we require authentication tokens for those urls then we should consider creating api tokens not user tokens. Those tokens should be embedded in url then. So applicaster clients can use them.

feat: add preview url to videos table

Is your feature request related to a problem? Please describe.

We need to provide preview url for our front-end so we can see on video cell.

Describe the solution you'd like

Extend videos table with preview url, so it looks as follows:

VIDEOS TABLE

Key Type
ID unique id
URL string
PREVIEW string
TITLE string
PUBLISHED int(date)
SOURCE string
CHANNEL string
DURATION int
ARCHIVED bool
FREE_TO_REUSE bool
AUTHORISED_TO_REUSE bool

docs: Create Pull Request template

Describe the bug/feature

There is no pull request template for this repository as of now. Therefore the pull request template mentioned below needs to be created and placed in .github folder (so that it gets preloaded).

Template attached below:

### Description

Include a summary of the change and relevant motivation/context. List any dependencies that are required for this change.

Fixes # [ISSUE]

### Type of Change:
**Delete irrelevant options.**

- Code
- Quality Assurance
- User Interface
- Outreach
- Documentation

**Code/Quality Assurance Only**
- Bugfix (non-breaking change which fixes an issue)
- This change requires a documentation update (software upgrade on readme file)
- New feature (non-breaking change which adds functionality pre-approved by mentors)



### How Has This Been Tested?
Describe the tests you ran to verify your changes. Provide instructions or GIFs so we can reproduce. List any relevant details for your test.


### Checklist:
**Delete irrelevant options.**

- [ ] My PR follows the style guidelines of this project
- [ ] I have performed a self-review of my own code or materials
- [ ] I have commented on my code or provided relevant documentation, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] Any dependent changes have been merged
- [ ] I have written Docs whenever is applicable


**Code/Quality Assurance Only**
- [ ] My changes generate no new warnings
- [ ] My PR currently breaks something (fix or feature that would cause existing functionality to not work as expected)
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been published in downstream modules

Expected behavior

  • Created a ./github/PULL_REQUEST_TEMPLATE.md
  • Pull request template is preloaded when contributor clicks new pull request

Expected time to complete: 1 hour

Bug : Errors in Readme.md

Describe the bug

The json file downloaded from firebase console is to be renamed as 'google-credentials.json' instead of 'firebase-cred.json'

Screenshot from 2021-01-28 17-32-33

Desktop (please complete the following information):

  • OS: Ubuntu 20.04
  • Browser Firefox

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.