Skip to content

anishomsy/videoshare

Repository files navigation

VideoShare Video

Table of Contents

Description

VideoShare is a videosharing site that allowes users to share video, and interact with the video. VideoShare was built using Django as a backend and JavaScript the frontend.

Distinctiveness and Complexity

  • VideoShare uses NodeJs and Vite
  • Use of Class Based Views
  • Use of Django built-in auth views
  • Use of 6 different models
  • Use of django built-in forms to supplement my own
  • Use of python-ffmpeg to generate video thumbnail
  • Use of django file upload storage method

Files and Directory Structure

Here, I'll provide an overview of the main files and directories in the project and how they contribute to the functionality of VideoShare:

  • media/: This directory is used to store user-uploaded media files, such as videos and images.

  • project5/: The root directory of the Django project.

  • static/: This directory contains static assets like JavaScript, CSS, and images.

    • dist/: Compiled and minified assets generated by Vite.

    • src/: The source directory for static assets.

      • css/: CSS files for styling the application.

      • js/: JavaScript files responsible for various functionalities:

      • scss/: SCSS files for styling the application using Sass.

  • templates/: Contains HTML templates used by Django to render pages.

    • Various HTML templates like history.html, index.html, layout.html, and others, each representing different parts of the application's user interface.
  • videoshare/: The main Django app for VideoShare.

    • migrations/: Contains database migration files.

    • MyVideos.py: Logic for managing user's own videos.

    • admin.py: Django admin configurations.

    • apps.py: Django app configuration.

    • fileuploader.py: Logic for handling file uploads.

    • forms.py: Django forms for user input.

    • models.py: Defines the database models for VideoShare.

    • tests.py: Unit tests for the app.

    • urls.py: URL routing for the app, mapping URLs to views.

    • views.py: Contains class-based views and functions that handle user interactions.

  • README.md: Documentation providing an overview of the project, how to set it up, and its main features.

Installation and Usage

Install nodejs and python

git clone https://github.com/me50/ananito/blob/web50/projects/2020/x/capstone.git
cd capstone
pip install -r requirements.txt
mkdir media media/uploads/ media/uploads/images media/uploads/videos static/dist
npm install
npx vite
python manage.py makemigrations
python manage.py runserver

More Info

Views

  • views.py:

    • index(request): Renders the index page with a list of videos.

    • register(request): Handles user registration. Allows users to create accounts.

    • watch_view(request): Displays a video for viewing.

    • like_dislike(request, action): Handles likes and dislikes for videos.

    • update_views(request, video_id): Updates video views when a user watches a video.

    • random_video(self): Redirects users to a random video.

    • most_viewed_videos(request): Displays a list of videos sorted by the number of views.

    • new_comment(request): Adds new comments to videos.

    • CommentLikes(request): Handles likes on comments.

    • history_view(request): Displays the user's video view history.

    • getVideoInfo(request, video_id): Fetches video information.

    • search_view(request): Displays search results for videos.

  • MyVideos: Class based View

    • post(self, request): Update the details of a user's uploaded video.
    • delete(self, request, video_id): Delete a user's uploaded video.
    • get(self, request): View a list of videos uploaded by the logged-in user.
  • fileuploader: Video Upload functions

    • get(self, request): Redirect to homepage.
    • post(self, request): Upload a video along with title, description, thumbnail(optional), and privacy settings.
    • generate_thumbnail(self, video): Generates a thumbnail image for the uploaded video at a random time within the video's duration.
    • generate_video_id(self): Generates a unique video ID of length 8 using letters, digits, underscores, and hyphens. Returns a unique video ID that doesn't already exist in the database.
    • is_valid_video_file(self, video): Checks if the uploaded video file is mp4 based on its content type.

Models

User Model

The User model extends Django's built-in AbstractUser model, representing registered users of the application.

VideoUpload Model

The VideoUpload model represents uploaded videos and their associated details. Each video has the following attributes:

  • unique_id: A unique UUID generated for each video.
  • user: A foreign key to the user who uploaded the video.
  • title: The title of the video.
  • description: The description of the video (optional).
  • video: The video file uploaded by the user.
  • thumbnail: An optional thumbnail image for the video.
  • private: A boolean field indicating whether the video is private.
  • views: The number of views the video has received.
  • video_id: A unique identifier for the video.
  • date: The timestamp when the video was uploaded.

Like Model

The Like model represents likes and dislikes for videos. Each like has the following attributes:

  • video: A foreign key to the associated video.
  • liked_by: A ManyToMany field containing users who liked the video.
  • disliked_by: A ManyToMany field containing users who disliked the video.
  • date: The timestamp when the like was recorded.

UserViewHistory Model

The UserViewHistory model tracks the viewing history of users. It has the following attributes:

  • user: A foreign key to the user whose history is being tracked.
  • videos: A ManyToMany field containing videos viewed by the user.
  • date: The timestamp when the history entry was recorded.

Comment Model

The Comment model represents comments made by users on videos. Each comment has the following attributes:

  • user: A foreign key to the user who made the comment.
  • comment: The text of the comment.
  • video: A foreign key to the associated video.
  • likes: The number of likes received by the comment.
  • created_at: The timestamp when the comment was created.

CommentLike Model

The CommentLike model tracks likes on comments. Each comment like has the following attributes:

  • comment: A foreign key to the associated comment.
  • user: A ManyToMany field containing users who liked the comment.
  • date: The timestamp when the like was recorded.

Forms

UserRegistrationForm

The UserRegistrationForm class is a custom form that extends Django's built-in UserCreationForm. It provides a registration form for new users to sign up for the VideoShare platform. The form includes the following fields:

  • username: The desired username for the user's account.
  • first_name: The user's first name.
  • last_name: The user's last name.
  • email: The user's email address.
  • password1: The user's desired password.
  • password2: The confirmation of the user's password.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published