Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add server3 #18

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8996468
Update .gitignore
qedpi Jan 17, 2021
87ed139
Update .gitignore
qedpi Jan 17, 2021
3b5fa26
add api key
qedpi Jan 17, 2021
c1bd3be
comment out sidebar & right menu
qedpi Jan 17, 2021
0ccd0c6
added logo + search bar len
andy0207huang Jan 17, 2021
21ae112
commenting out
andy0207huang Jan 17, 2021
66021c7
default text
andy0207huang Jan 17, 2021
35a74c4
Set theme jekyll-theme-slate
mkadiya20 Mar 6, 2021
1a8a1c3
Update .gitignore
qedpi Mar 7, 2021
14e826b
Create app.py
qedpi Mar 7, 2021
01b71dd
fix API key code
qedpi Mar 7, 2021
2ca7eaf
add API section to readme
qedpi Mar 7, 2021
5e57176
add API call examples
qedpi Mar 7, 2021
dbb8111
add option to specify video link
qedpi Mar 7, 2021
1f2bb8e
add yarn script to run flask server
qedpi Mar 7, 2021
791b5be
install axios
qedpi Mar 7, 2021
76d8bde
add CORS for flask GET request
qedpi Mar 7, 2021
84d49a1
connect backend & simulate range clicks
qedpi Mar 7, 2021
da20d26
improve UI of ranges
qedpi Mar 7, 2021
19fc191
take care of edge case (final range)
qedpi Mar 7, 2021
69013b7
fix indentation style
qedpi Mar 8, 2021
adc288a
Update .gitignore
qedpi Mar 8, 2021
9a7afb3
enable click to seekto feature
qedpi Mar 8, 2021
6e87f92
fix width misalignment
qedpi Mar 8, 2021
fd3fa3c
add todos
qedpi Mar 9, 2021
86a0298
contribution and versioning pipeline
qedpi Mar 9, 2021
b7353da
Adding my tasks
npysklyw Mar 10, 2021
7fe86c0
Update README.md
rb2001 Mar 13, 2021
efb925f
Update README.md
rb2001 Mar 13, 2021
e1cbb33
change mouseover cursor to pointer
qedpi Mar 14, 2021
b771d2e
Merge branch 'master' of https://github.com/wai-ad-astra/htn-cucai-se…
qedpi Mar 14, 2021
01133cd
Delete logoMYTube.jpg
andy0207huang Mar 14, 2021
9623ed6
Update package.json
mkadiya20 Mar 14, 2021
dd1f16b
initial UI changes
rb2001 Mar 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.idea

*.css
# See https://help.github.com/ignore-files/ for more about ignoring files.

keys.js
.idea

# dependencies
/node_modules

Expand All @@ -20,3 +25,7 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea/workspace.xml
.idea/misc.xml
.idea/workspace.xml
.idea/youtube-react.iml
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
# task assignment guide
- pick a task & use ~~strikeout~~ to assign it to yourself
- when complete, document it well!
- (if code) create new branch named after task
- ask someone to code-review
- merge into main branch
- move item from todo to current version

# todos
- background
- find youtube views distribution or how many vids have 1 million views in total
- frontend
- ~~improve the UI - use template from figma to make it similar~~
- refactor code to adhere to react best practices
- ~~next/prev occurence, next/prev object keyboard shortcut~~
- backend
- ~~find out how to use colab as backend / server, and tie GET endpoints to code cell execution~~
- ~~fix colab inference code~~
- ~~[use python 3.8](https://stackoverflow.com/questions/60775160/install-python-3-8-kernel-in-google-colaboratory)~~
- ML
- ~~get range training data: a bunch of youtube videos with chapters and or highlights~~
- ~~check if uoft labeling suite is avail, and how to use it for polygon labeling~~
- ~~novel object labeling pipeline~~
- literature review
- topic modeling (subititles) & visual topic modeling
- ~~pic to caption models~~
- text summarization

# versions
## 0.0.1 (current)

## 0.0.0
- front: display highlights as colored div using dummy data
- back: download vid, extract frames, save annotation

# [API interface](https://console.developers.google.com/apis/credentials?pli=1&project=cansumcam)
or [create your own credentials](https://console.developers.google.com/apis/credentials)
![location](./readme/API_interface.png)

# yarn scripts
- yarn start
- dev server hosting react client @localhost:3000
- yarn server
- dev server hosting flask server @localhost:5000

# REST calls
- localhost:5000 for dev
- prod TBD
- POST a video link to be analyzed
- http://localhost:5000/bookmarks/?videoID=foo
- get back a list of occurrence ranges for all objects
![occurence range for all objects](./readme/all_occurence_ranges.png)
- http://localhost:5000/bookmarks/?videoID=foo&object_name=bar
- specify an object
![occurrence range for named object](./readme/obj_occurence_range.png)

# videos
App > Watch > WatchContent > VideoInfoBox


# 1 About

This repository is the source code for the epic length [Build Youtube in React](https://productioncoder.com/build-youtube-in-react-part-1/) tutorial series provided by [productioncoder.com](https://productioncoder.com).
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-slate
80 changes: 80 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.21.1",
"javascript-time-ago": "^2.0.13",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-linkify": "^1.0.0-alpha",
"react-player": "^2.7.2",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-test-renderer": "^16.13.1",
"react-waypoint": "^9.0.3",
"react-youtube": "^7.13.1",
"redux": "^4.0.5",
"redux-saga": "^1.1.3",
"reselect": "^4.0.0",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^1.2.0"
},
"scripts": {
"server": "python ./server/app.py",
"server3": "python3 ./server/app.py",
"dev": "source .env.local && npm start",
"start": "react-scripts start",
"build": "react-scripts build",
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>MyTube</title>
<title>CANSUMCAM</title>
</head>
<body>
<noscript>
Expand Down
Binary file added public/videos/video-output-2.mkv
Binary file not shown.
Binary file added public/videos/video-output.mp4
Binary file not shown.
Binary file added readme/API_interface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/all_occurence_ranges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/obj_occurence_range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions server/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# pip install pytube3 --upgrade

from flask import Flask, jsonify, request
from flask_cors import cross_origin, CORS
# usage guide: https://flask-cors.readthedocs.io/en/latest/

app = Flask(__name__)
CORS(app)
app.config['CORS_SUPPORTS_CREDENTIALS'] = True
# https://stackoverflow.com/questions/61955973/issue-with-flask-cors-blocked-by-cors-policy-response-to-preflight-request-do
# https://github.com/corydolphin/flask-cors/issues/200
# app.config['CORS_HEADERS'] = 'Content-Type'

DUMMY_DICT = {
'boat': [[5, 10], [30, 45]],
'fish': [[15, 500]],
'kite': [[15, 20], [50, 80]],
'chair': [[60, 200]]
}


@app.route('/')
def hello_world():
return 'Hello World!'


@app.route('/bookmarks/', methods=['GET', 'POST'])
@cross_origin() # enables CORS POST, for GET: response.headers.add("Access-Control-Allow-Origin", "*")
def get_bookmarks():
query_parameters = request.args
video_ID = query_parameters.get('videoID')
object_name = query_parameters.get('object_name')

result = None
if video_ID:
if object_name:
print(f'for {object_name}')
result = DUMMY_DICT.get(object_name, {})
else:
print('all objects')
result = DUMMY_DICT
else:
# use dummy return
result = DUMMY_DICT
return jsonify(result) # {} means not found!


if __name__ == '__main__':
app.run(host="127.0.0.1",port=5000)
8 changes: 7 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import {youtubeLibraryLoaded} from './store/actions/api';
import Trending from './containers/Trending/Trending';
import Search from './containers/Search/Search';

const API_KEY = process.env.REACT_APP_YT_API_KEY;
import API_KEY_YOUTUBE from './keys.js';

const API_KEY = process.env.REACT_APP_YT_API_KEY || API_KEY_YOUTUBE;
//const API_KEY = API_KEY_YOUTUBE;

console.log('API key: ' + JSON.stringify(API_KEY));

class App extends Component {
render() {
Expand All @@ -24,6 +29,7 @@ class App extends Component {
</AppLayout>
);
}

componentDidMount() {
this.loadYoutubeApi();
}
Expand Down
Binary file modified src/assets/images/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/Rating/Rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export function Rating(props) {
}
return (
<div className='rating'>
<div >
{/* <div >
<Icon name='thumbs outline up'/>
<span>{likeCount}</span>
</div>
<div >
<Icon name='thumbs outline down'/>
<span>{dislikeCount}</span>
</div>
{rating}
{rating} */}
</div>
);
}
4 changes: 2 additions & 2 deletions src/components/RelatedVideos/NextUpVideo/NextUpVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export function NextUpVideo(props) {
return (
<React.Fragment>
<div className='next-up-container'>
<h4>Up next</h4>
{/* <h4>Up next</h4>
<div className='up-next-toggle'>
<span>Autoplay</span>
<Checkbox toggle defaultChecked/>
</div>
</div> */}
</div>
<VideoPreview horizontal={true} video={props.video} pathname='/watch' search={`?v=${props.video.id}`}/>
<Divider/>
Expand Down
Loading