{"id":27171946,"url":"https://github.com/bkocis/you-search-and-stream","last_synced_at":"2025-04-09T09:19:35.404Z","repository":{"id":286894299,"uuid":"962903776","full_name":"bkocis/you-search-and-stream","owner":"bkocis","description":"A web-based media player that enables searching and downloading music from YouTube and SoundCloud with a clean playback interface. This repository demonstrates complete CI/CD implementation using GitHub Actions for automated deployment to remote servers.","archived":false,"fork":false,"pushed_at":"2025-04-08T21:24:22.000Z","size":454,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T22:27:26.509Z","etag":null,"topics":["deployment","soundcloud","streaming-audio","streaming-video","youtube-downloader","youtube-video"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bkocis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-08T21:16:04.000Z","updated_at":"2025-04-08T21:26:38.000Z","dependencies_parsed_at":"2025-04-08T22:37:53.778Z","dependency_job_id":null,"html_url":"https://github.com/bkocis/you-search-and-stream","commit_stats":null,"previous_names":["bkocis/you-search-and-stream"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkocis%2Fyou-search-and-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkocis%2Fyou-search-and-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkocis%2Fyou-search-and-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bkocis%2Fyou-search-and-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bkocis","download_url":"https://codeload.github.com/bkocis/you-search-and-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008625,"owners_count":21032556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deployment","soundcloud","streaming-audio","streaming-video","youtube-downloader","youtube-video"],"created_at":"2025-04-09T09:19:34.762Z","updated_at":"2025-04-09T09:19:35.390Z","avatar_url":"https://github.com/bkocis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n---\n\n# Media Player, Search \u0026 Downloader\n\nA web-based media player and downloader application that allows you to download, store, and play media content from YouTube and SoundCloud. The application is designed to be deployed on a remote server, providing a centralized media library accessible through a web interface.\n\nIndex page with the media player, media types, playlist creation, and item deletion: \n\u003cdiv align=\"center\"\u003e \u003cimg src=\"templates/assets/player.jpg\" width=\"600\"\u003e \u003c/div\u003e\n\n\u003cbr\u003e \n\nDownload page with search \n\u003cdiv align=\"center\"\u003e \u003cimg src=\"templates/assets/search_and_download.jpg\" width=\"600\"\u003e \u003c/div\u003e\n\n\u003cbr\u003e \n\nSearch and select media\n\u003cdiv align=\"center\"\u003e \u003cimg src=\"templates/assets/downloadpage.jpg\" width=\"600\"\u003e \u003c/div\u003e\n\n# Disclaimer \n\n📣 The frontend-part of this application (css, js, html) was purely and entirely coded with Cursor AI Code Editor, without technical supervision. Although, the main functionalities have been tested qualitatively, it is by no means perfect. The code provided here can be also used as a statement about the capabilities and limitation of AI generated code (in the frame of [Cursor - The AI Code Editor](https://www.cursor.com/) - written on 29.03.2025).\n\n📣 This code does not promote downloading video material, it just provides a player for streaming any media you have.\n\nDownloading videos from YouTube, including music videos, is generally against YouTube's Terms of Service (ToS) \nunless you have explicit permission from the copyright holder or \nYouTube provides an official download option. YouTube explicitly states that users may not download content unless:\n\n- There's a download button provided by YouTube.\n- The content is available through YouTube Premium (which allows offline viewing).\n- You have express permission from the copyright owner.\n\nCopyright Law and Legal Considerations\n\n- Most music videos are copyrighted, downloading them without permission could violate copyright laws.\n- YouTube Premium: Allows official downloads for offline viewing.\n- Creative Commons \u0026 Public Domain Content: Some videos on YouTube are legally downloadable if they are licensed under Creative Commons.\n\nBy using this code you may violate YouTube's ToS causing account suspension, banning, or possible copyright infringement (legal consequences, fines).\n\n\n\n## Features\n\n- **Media Download**\n  - Download videos and audio from YouTube\n  - Download tracks from SoundCloud\n  - Automatic audio extraction from videos\n  - Thumbnail and description preservation\n  - Progress tracking during downloads\n\n- **Media Player**\n  - Web-based media player interface\n  - Support for both audio and video playback\n  - Streaming capabilities with range request support\n  - Organized media library with thumbnails\n  - File management (delete, sort, search)\n\n- **YouTube Integration**\n  - Built-in YouTube search functionality using `yt-dlp` (with [daily latest version](https://pypi.org/project/yt-dlp/#history))\n  - Direct download from search results\n  - High-quality thumbnail support\n\n## Technical Stack\n\n- **Backend**: Python/Flask\n- **Frontend**: HTML/JavaScript\n- **Real-time Updates**: Flask-SocketIO\n- **Media Processing**: moviepy, ffmpeg\n- **Download Tools**: yt-dlp, youtube-dl\n- **Containerization**: Docker\n- **CI/CD**: GitHub Actions\n\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone \u003crepository-url\u003e\ncd youtube-scraping\n```\n\n2. Install Python dependencies:\n```bash\npip install -r requirements.txt\n```\n\n3. Use `make` to run the app locally, or to run containerization and deployment. \n\n\n## Project Structure\n\n```\n.\n├── .github/workflow       # GitHub Actions workflows\n├── templates/            # HTML pages, css, js \n├── downloads/            # Media storage directory - all media files (audio, video, images) will be stored here\n├── Dockerfile            # Container configuration\n├── Makefile             # run configuration for managing deployment scenarios\n└── webplayer.py          # Main application in python flask \n\n```\n\n## API Endpoints\n\nThe following endpoint define the main functionality of the flask application.\n\n- `/download`: Media download interface\n- `/media`: List available media files\n- `/stream/\u003cfilename\u003e`: Stream media files\n- `/search`: YouTube search functionality\n\n## Security Considerations\n\n- The application uses secure file handling and sanitization\n- Media files are stored in a dedicated directory\n- File access is controlled through the web interface\n- No direct file system access is exposed\n\n\n---\n\n## Deployment and updating the yt-dlp\n\nIn you deployment server, you need to define an environmental variable $MEDIA_STREAMER_LOCAL_PATH, pointing to the path of the project. \nAdd it to the .bashrc for convenience. \n\nThe cronjob command is then:\n\n`0 4 * * * /bin/bash -c \"source /root/.bashrc \u0026\u0026 cd $MEDIA_STREAMER_LOCAL_PATH \u0026\u0026 make restart_docker\" \u003e\u003e /tmp/cron.log 2\u003e\u00261`\n\n## Setting up Github Workflow for a remote server deployment \n\n### Setting up connection between the runner and the remote server\n\n__On the remote machine:__ \n\nGenerate a new key pair: \n\n`ssh-keygen -t ed25519 -f github_actions_key -N \"\"`\n\nAdd the public key (contents of github_actions_key.pub) to your server's ~/.ssh/authorized_keys file\n\n\n__On Github Action Secrets define:__ \n\nAdd the private key (contents of github_actions_key) to your GitHub secrets as SSH_PRIVATE_KEY\n\n\n```bash\nSSH_PRIVATE_KEY - the above mentioned `github_actions_key`\nSERVER_HOST - hostname/IP\nSERVER_USER - username \nMEDIA_STREAMER_LOCAL_PATH \n```\n\nThe `MEDIA_STREAMER_LOCAL_PATH` would be required, if there are multiple projects deployed on the server. It could be for example: \"/home/Projects/youtube-rocket\"\n\n### How it works: \n\nThe main part of the deployment is to trigger the `restart_docker` target in the Makefile. This is out of convenience, as all the docker commands are defined in the Makefile for ease of execution.  \n\n```yaml\n    - name: Execute remote command\n      run: |\n        ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} 'cd ${{ secrets.MEDIA_STREAMER_LOCAL_PATH }} \u0026\u0026 make restart_docker'\n```\n\nThe section: \n\n```yaml\n    - name: Set up SSH key with debugging\n      run: |\n        mkdir -p ~/.ssh\n        echo \"${{ secrets.SSH_PRIVATE_KEY }}\" \u003e ~/.ssh/id_rsa\n        chmod 600 ~/.ssh/id_rsa\n        ls -la ~/.ssh/id_rsa\n        ssh-keyscan -H ${{ secrets.SERVER_HOST }} \u003e\u003e ~/.ssh/known_hosts\n\n```\n\nis setting up SSH key authentication with added debugging commands to help troubleshoot connection issues. Here's what each line does:\n\n`mkdir -p ~/.ssh` creates the .ssh directory in the runner's home folder if it doesn't already exist. The `-p` flag prevents errors if the directory already exists.\n\n`echo \"${{ secrets.SSH_PRIVATE_KEY }}\" \u003e ~/.ssh/id_rsa` takes the private SSH key stored in GitHub Secrets and writes it to the id_rsa file in the .ssh directory. This is the standard location for the default SSH private key.\n\n`chmod 600 ~/.ssh/id_rsa` sets the correct permissions on the private key file. SSH requires private keys to be readable only by the owner (not by group or others) for security reasons.\n\n`ls -la ~/.ssh/id_rsa` a debugging command that displays the permissions, size, and other details of the SSH key file. It helps verify that the file exists and has the correct permissions (should show \"-rw-------\" or similar).\n\n`ssh-keyscan -H ${{ secrets.SERVER_HOST }} \u003e\u003e ~/.ssh/known_hosts`  __automatically adds the server's SSH host key to the known_hosts file to prevent \"host authenticity\" prompts during the connection.__\n\nThis entire section is designed to both set up the SSH connection and provide diagnostic information if something goes wrong, which is helpful for debugging SSH connection issues like the one you encountered.\n\n-- Notes \n\nThis implementation still requires to have an env variable `MEDIA_STREAMER_LOCAL_PATH` added to the `.bashrc`.\n\n---\n\n## Planned functionality next steps and todo's\n\n- [✅] download youtube by link\n- [✅] convert video to audio at download time\n  - [ ] extend with option to remove video after download keeping only mp3\n- [✅] file deletion tab\n- [✅] description added (obtained when track in downloaded)\n- [ ] recommendation\n- [✅] search\n- [ ] \"what is this track?\" (Song recognition - Audio fingerprinting)\n- [ ] back-end tasks:\n  - [] indexing \n  - [] analytics \n\nFront-end \n- [ ] playlist \n  - [ ] play next track in playlist automatically \n  - [ ] add track to existing playlist\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkocis%2Fyou-search-and-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkocis%2Fyou-search-and-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkocis%2Fyou-search-and-stream/lists"}