Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
realaravinth committed May 24, 2020
0 parents commit c4fec9a
Show file tree
Hide file tree
Showing 171 changed files with 28,283 additions and 0 deletions.
138 changes: 138 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
1 change: 1 addition & 0 deletions copy-to-vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scp -P 2222 -r download-scripts aravinth@localhost:/home/aravinth/
10 changes: 10 additions & 0 deletions download-scripts/action-plan
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rating language release
rating-cell flag-cell <td><a href="sub link"


other uploader downlaod
other-cell uploader-cell download-cell

go to link form download-cell
and then get the link at <a class="btn-icon-download-subtitle"
{'class': ['uploader-cell']}
22 changes: 22 additions & 0 deletions download-scripts/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#---------------------------------------------------------------
# USAGE
#---------------------------------------------------------------
#Downloading:
# ./testing "magnet link or torrent link" "imdb id"



root="/home/aravinth/moviesBatsense/download-scripts"
source $root/env-vars.sh
start_time=$(date +"%F_%H-%M")
package="$tmp/$start_time/$2"


mkdir -p $package/temp

cd $package/temp

# downloading the torrent
transmission-cli -w . $1 >> $movies/$2-status.txt
$root/process.sh $package $2 $start_time
25 changes: 25 additions & 0 deletions download-scripts/download_img.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import requests, json
import sys

def get(url, data):
response = requests.get(url, params=data)
return response.json()

def search(query):
url = "https://yts.mx/api/v2/list_movies.json"
data ={
"query_term" : query,
"limit" : 50,
"quality" : "720p"
}
response = get(url, data)
data = response['data']
if response['status'] == "ok":
if data['movie_count'] == 0:
return 1
else:
return data['movies'][0]['medium_cover_image']
else:
return 1

print(search(sys.argv[1]))
37 changes: 37 additions & 0 deletions download-scripts/download_subs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from bs4 import BeautifulSoup
import sys
import requests

def yify_subs(url):
response = requests.get(url)
if response.ok:
return response
else:
yify_subs(url)

list_url = "https://www.yifysubtitles.com/movie-imdb/" + str(sys.argv[1])
response = yify_subs(list_url)
soup = BeautifulSoup(response.content, 'html.parser')
heading = soup.h4
if heading['class'][0] == 'modal-title':
print(1)
else:
while True:
try:
heading = heading.next_element
if heading == 'English':
target = heading.next_element.a
break
except:
break
subs_page = "https://www.yifysubtitles.com" + target.get('href')
response = yify_subs(subs_page)
soup = BeautifulSoup(response.content, 'html.parser')
for i in soup.find_all('a'):
try:
if i.attrs['class'][0] == 'btn-icon':
subs_link = i.get('href')
break
except:
continue
print(subs_link)
4 changes: 4 additions & 0 deletions download-scripts/env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
log="/home/aravinth/moviesBatsense/logs"
tmp="/home/aravinth/moviesBatsense/tmp"
movies="/home/aravinth/moviesBatsense/downloads/movies"
sub_bin="/home/aravinth/moviesBatsense/download-scripts/srt-vtt"
15 changes: 15 additions & 0 deletions download-scripts/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

root="/home/aravinth/moviesBatsense/download-scripts"
mkdir -p $root
source $root/env-vars.sh

mkdir -p $log $tmp $movies $sub_bin

cd $root

for exe in *
do
chmod +x $exe
done

96 changes: 96 additions & 0 deletions download-scripts/process.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash
#---------------------------------------------------------------
# USAGE
#---------------------------------------------------------------
#Downloading:
# ./process "package-dir" "imdb-id" "startime"


root="/home/aravinth/moviesBatsense/download-scripts"
source $root/env-vars.sh

package=$1

convert_sub(){
$sub_bin
rm *.srt
mv *.vtt $1.vtt
mv $1.vtt $package
}

convert_video(){
mv $1 $2
ffmpeg -i $2 -codec copy $2.mp4
mv $2.mp4 $package
}

cd $1/temp/*

# cleaning up junk
rm -r *.txt
rm -r *.jpg
rm -r *.png

# converting files
for file in *
do
if [ -d $file ]
then
rm -rf $file
fi
extention="${file##*.}"
name="${file%.*}"

if [ $extention == "srt" ]
then
convert_sub $2
else
status=$(/home/aravinth/venv/bin/python3.7 $root/download_subs.py $2)
if [ $status -eq 1 ]
then
sleep 0.00000001
else
curl $status --output $2.zip
unzip $2.zip
rm $2.zip
convert_sub $2
fi
fi
if [ $extention == "avi" ]
then
convert_video $file $2
fi
if [ $extention == "webm" ]
then
convert_video $file $2
fi
if [ $extention == "mkv" ]
then
convert_video $file $2
fi
if [ $extention == "mp4" ]
then
mv $file $2.mp4
mv $2.mp4 $package
fi

done

# Cleaning up temp
# cd ../$2

# mv * $1

# for file in *
# do
# mv $file $1
# done

cd $1
rm -rf temp
cd ..

# moving files into production
mv $1 $movies

rm -rf $tmp/$3
Binary file added download-scripts/srt-vtt
Binary file not shown.
5 changes: 5 additions & 0 deletions forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django import forms

class Search(forms.Form):
query = forms.CharField(label='query', max_length=100)

21 changes: 21 additions & 0 deletions 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', 'yts.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()
2 changes: 2 additions & 0 deletions notes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'/' added in yify.urls.py after search/<str:query>, check if it breakes site

Loading

0 comments on commit c4fec9a

Please sign in to comment.