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

User Register, Login and Password Reset added #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added .DS_Store
Binary file not shown.
Binary file removed lushlyrics-webapp-django-main.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions lushlyrics-webapp-django-main/.replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
language = "bash"
run = "pip install -r requirements.txt && python manage.py runserver 0.0.0.0:3000"
3 changes: 3 additions & 0 deletions lushlyrics-webapp-django-main/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "D:\\Python_Interpretor\\python.exe"
}
33 changes: 33 additions & 0 deletions lushlyrics-webapp-django-main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@



## Setup

The first thing to do is to clone the repository:

```sh
$ git clone https://github.com/mohammedwed/lushlyrics-webapp-django.git
$ cd lushlyrics-webapp-django
```

Create a virtual environment to install dependencies in and activate it:

```sh
$ virtualenv2 --no-site-packages env
$ source env/bin/activate
```

Then install the dependencies:

```sh
(env)$ pip install -r requirements.txt
```
Note the `(env)` in front of the prompt. This indicates that this terminal
session operates in a virtual environment set up by `virtualenv2`.

Once `pip` has finished downloading the dependencies:
```sh
(env)$ cd spotify-clone-django
(env)$ python manage.py runserver
```
And navigate to `http://127.0.0.1:8000/demo`.
938 changes: 938 additions & 0 deletions lushlyrics-webapp-django-main/card.json

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions lushlyrics-webapp-django-main/cardupdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from spotipy.oauth2 import SpotifyClientCredentials
import spotipy
from youtube_search import YoutubeSearch

PLAYLISTS = [['Accidental','https://open.spotify.com/playlist/0zJ8hC8YJOcHYuk5nMPFm8?si=U6Kyom3XQ32reSuVgl2uhA', "PL59eqqQABruMQOPlUVcVsIid685ZdwDjf"],
['TimePass','https://open.spotify.com/playlist/6gADLrLFK1kXgEEOsENi1c', "PL59eqqQABruMSx6VSy1hbkBhG4XwtgSuy"],
['CHILLS','https://open.spotify.com/playlist/3zs3QOLX8bASY5oV2dmEQw', 'PL59eqqQABruN3GyAPiPnQ6Jq-TngWjT-Y'],
['Programming & Coding Music','https://open.spotify.com/playlist/6vWEpKDjVitlEDrOmLjIAj', 'PL59eqqQABruNew5O0cRvomfbU6FI0RGyl'],
['Spanish','https://open.spotify.com/playlist/75QJ1JeFaeSm0uH1znWxb0?si=Lt4kd-RARBu2TQz35RAQiQ', 'PL59eqqQABruM3TLAGthvgW10c1R6omGwq']
]
client_credentials_manager = SpotifyClientCredentials(client_id='e5d66c188ef64dd89afa4d13f9555411',
client_secret='d070988d7bd5479a9e0818fa23839544')
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)



CONTAINER = []
for playlist in PLAYLISTS:
Name,Link,playlistid = playlist
playlistcard = []
count = 0
PlaylistLink = "http://www.youtube.com/watch_videos?video_ids="
for i in (sp.playlist_tracks(Link)['items']):
if count == 50:
break
try:
song = i['track']['name'] + i['track']['artists'][0]['name']
songdic = (YoutubeSearch(song, max_results=1).to_dict())[0]
playlistcard.append([songdic['thumbnails'][0],songdic['title'],songdic['channel'],songdic['id']])
PlaylistLink += songdic['id'] + ','
except:
continue
count += 1

from urllib.request import urlopen
req = urlopen(PlaylistLink)
PlaylistLink = req.geturl()
print(PlaylistLink)
PlaylistId = PlaylistLink[PlaylistLink.find('list')+5:]

CONTAINER.append([Name,playlistcard,playlistid])

import json

json.dump(CONTAINER,open('card.json', 'w'),indent = 6)
Binary file not shown.
Binary file added lushlyrics-webapp-django-main/db.sqlite3
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions lushlyrics-webapp-django-main/main/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import playlist_user, playlist_song
# Register your models here.
admin.site.register(playlist_user)
admin.site.register(playlist_song)
35 changes: 35 additions & 0 deletions lushlyrics-webapp-django-main/main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 3.0.7 on 2020-11-17 13:13

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='playlist_user',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=200)),
],
),
migrations.CreateModel(
name='playlist_song',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('song_title', models.CharField(max_length=200)),
('song_youtube_id', models.CharField(max_length=20)),
('song_albumsrc', models.CharField(max_length=255)),
('song_dur', models.CharField(max_length=7)),
('song_channel', models.CharField(max_length=100)),
('song_date_added', models.CharField(max_length=12)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.playlist_user')),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions lushlyrics-webapp-django-main/main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.db import models


# Create your models here.
class playlist_user(models.Model):
username = models.CharField(max_length=200)

def __str__(self):
return f'Username = {self.username}, Liked Songs = {list(self.playlist_song_set.all())}'

class playlist_song(models.Model):
user = models.ForeignKey(playlist_user, on_delete=models.CASCADE)
song_title = models.CharField(max_length=200)
song_youtube_id = models.CharField(max_length=20)
song_albumsrc = models.CharField(max_length=255)
song_dur = models.CharField(max_length=7)
song_channel = models.CharField(max_length=100)
song_date_added = models.CharField(max_length=12)

def __str__(self):
return f'Title = {self.song_title}, Date = {self.song_date_added}'


11 changes: 11 additions & 0 deletions lushlyrics-webapp-django-main/main/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.conf import settings
from django.conf.urls.static import static
from django.urls import path

from . import views

urlpatterns = [
path("", views.default, name='default'),
path("playlist/", views.playlist, name='playlist'),
path("search/", views.search, name='search')
]
78 changes: 78 additions & 0 deletions lushlyrics-webapp-django-main/main/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import json

from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.http.response import HttpResponse
from django.shortcuts import redirect, render
from django.urls.base import reverse
from youtube_search import YoutubeSearch

from .models import playlist_user

# import cardupdate



f = open('card.json', 'r')
CONTAINER = json.load(f)
@login_required(login_url="/users/login/")
def default(request):
global CONTAINER


if request.method == 'POST':

add_playlist(request)
return HttpResponse("")

song = 'kSFJGEHDCrQ'
return render(request, 'player.html',{'CONTAINER':CONTAINER, 'song':song})


@login_required(login_url="/users/login/")
def playlist(request):
cur_user = playlist_user.objects.get(username = request.user)
try:
song = request.GET.get('song')
song = cur_user.playlist_song_set.get(song_title=song)
song.delete()
except:
pass
if request.method == 'POST':
add_playlist(request)
return HttpResponse("")
song = 'kSFJGEHDCrQ'
user_playlist = cur_user.playlist_song_set.all()
# print(list(playlist_row)[0].song_title)
return render(request, 'playlist.html', {'song':song,'user_playlist':user_playlist})

@login_required(login_url="/users/login/")
def search(request):
if request.method == 'POST':

add_playlist(request)
return HttpResponse("")
try:
search = request.GET.get('search')
song = YoutubeSearch(search, max_results=10).to_dict()
song_li = [song[:10:2],song[1:10:2]]
# print(song_li)
except:
return redirect('/')

return render(request, 'search.html', {'CONTAINER': song_li, 'song':song_li[0][0]['id']})




def add_playlist(request):
cur_user = playlist_user.objects.get(username = request.user)

if (request.POST['title'],) not in cur_user.playlist_song_set.values_list('song_title', ):

songdic = (YoutubeSearch(request.POST['title'], max_results=1).to_dict())[0]
song__albumsrc=songdic['thumbnails'][0]
cur_user.playlist_song_set.create(song_title=request.POST['title'],song_dur=request.POST['duration'],
song_albumsrc = song__albumsrc,
song_channel=request.POST['channel'], song_date_added=request.POST['date'],song_youtube_id=request.POST['songid'])
21 changes: 21 additions & 0 deletions lushlyrics-webapp-django-main/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'youtify.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
4 changes: 4 additions & 0 deletions lushlyrics-webapp-django-main/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Django
youtube-search
spotipy
youtube-search
Loading