diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba9f5c2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +fontawesome/* +vendor/* \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..436b9fc --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +## For Install it ## + +You'll need +* composer + +Then, download and extract the zip file for download fontawesome on server ROOT +``` +wget https://use.fontawesome.com/releases/v5.15.1/fontawesome-free-5.15.1-web.zip +unzip fontawesome-free-5.15.1-web.zip +rm fontawesome-free-5.15.1-web.zip +mv fontawesome-free-5.15.1-web fontawesome +``` + +And download composer packages +``` +composer install +``` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..2e94701 --- /dev/null +++ b/composer.json @@ -0,0 +1,6 @@ +{ + "require": { + "php-ffmpeg/php-ffmpeg": "^0.16.0", + "daverandom/resume": "^0.0.3" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..8ce6704 --- /dev/null +++ b/composer.lock @@ -0,0 +1,636 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "b42c827937c1319b1e2c6401cea9c0fa", + "packages": [ + { + "name": "alchemy/binary-driver", + "version": "v5.2.0", + "source": { + "type": "git", + "url": "https://github.com/alchemy-fr/BinaryDriver.git", + "reference": "e0615cdff315e6b4b05ada67906df6262a020d22" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alchemy-fr/BinaryDriver/zipball/e0615cdff315e6b4b05ada67906df6262a020d22", + "reference": "e0615cdff315e6b4b05ada67906df6262a020d22", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0|^2.0|^1.0", + "php": ">=5.5", + "psr/log": "^1.0", + "symfony/process": "^2.3|^3.0|^4.0|^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0|^5.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Alchemy": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Le Goff", + "email": "legoff.n@gmail.com" + }, + { + "name": "Romain Neutron", + "email": "imprec@gmail.com", + "homepage": "http://www.lickmychip.com/" + }, + { + "name": "Phraseanet Team", + "email": "info@alchemy.fr", + "homepage": "http://www.phraseanet.com/" + }, + { + "name": "Jens Hausdorf", + "email": "mail@jens-hausdorf.de", + "homepage": "https://jens-hausdorf.de", + "role": "Maintainer" + } + ], + "description": "A set of tools to build binary drivers", + "keywords": [ + "binary", + "driver" + ], + "time": "2020-02-12T19:35:11+00:00" + }, + { + "name": "daverandom/resume", + "version": "v0.0.3", + "source": { + "type": "git", + "url": "https://github.com/DaveRandom/Resume.git", + "reference": "3d1c11b6c4315dd8d25d6f567c5ea392c7c60edb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/DaveRandom/Resume/zipball/3d1c11b6c4315dd8d25d6f567c5ea392c7c60edb", + "reference": "3d1c11b6c4315dd8d25d6f567c5ea392c7c60edb", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "DaveRandom\\Resume\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "mit" + ], + "authors": [ + { + "name": "Chris Wright", + "email": "me@daverandom.com" + } + ], + "description": "Tiny library to facilitate resumable downloads", + "time": "2018-01-28T03:18:55+00:00" + }, + { + "name": "doctrine/cache", + "version": "1.10.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "13e3381b25847283a91948d04640543941309727" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/13e3381b25847283a91948d04640543941309727", + "reference": "13e3381b25847283a91948d04640543941309727", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "doctrine/coding-standard": "^6.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "time": "2020-07-07T18:54:01+00:00" + }, + { + "name": "evenement/evenement", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Evenement": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "time": "2017-07-23T21:35:13+00:00" + }, + { + "name": "neutron/temporary-filesystem", + "version": "2.4", + "source": { + "type": "git", + "url": "https://github.com/romainneutron/Temporary-Filesystem.git", + "reference": "3c55497da8d7762fb4dcabc91d54a5de510e3c99" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/romainneutron/Temporary-Filesystem/zipball/3c55497da8d7762fb4dcabc91d54a5de510e3c99", + "reference": "3c55497da8d7762fb4dcabc91d54a5de510e3c99", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0", + "symfony/filesystem": "^2.3 || ^3.0 || ^4.0 || ^5.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^5.0.4" + }, + "type": "library", + "autoload": { + "psr-0": { + "Neutron": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Romain Neutron", + "email": "imprec@gmail.com" + } + ], + "description": "Symfony filesystem extension to handle temporary files", + "time": "2020-02-17T15:27:36+00:00" + }, + { + "name": "php-ffmpeg/php-ffmpeg", + "version": "v0.16", + "source": { + "type": "git", + "url": "https://github.com/PHP-FFMpeg/PHP-FFMpeg.git", + "reference": "4175c02b7d9f7e1a02cec2ba73474266ba2c5fa1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-FFMpeg/PHP-FFMpeg/zipball/4175c02b7d9f7e1a02cec2ba73474266ba2c5fa1", + "reference": "4175c02b7d9f7e1a02cec2ba73474266ba2c5fa1", + "shasum": "" + }, + "require": { + "alchemy/binary-driver": "^1.5 || ~2.0.0 || ^5.0", + "doctrine/cache": "^1.0", + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "neutron/temporary-filesystem": "^2.1.1", + "php": "^5.3.9 || ^7.0" + }, + "require-dev": { + "sami/sami": "~1.0", + "silex/silex": "~1.0", + "symfony/phpunit-bridge": "^5.0.4" + }, + "suggest": { + "php-ffmpeg/extras": "A compilation of common audio & video drivers for PHP-FFMpeg" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.7-dev" + } + }, + "autoload": { + "psr-0": { + "FFMpeg": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Romain Neutron", + "email": "imprec@gmail.com", + "homepage": "http://www.lickmychip.com/" + }, + { + "name": "Phraseanet Team", + "email": "info@alchemy.fr", + "homepage": "http://www.phraseanet.com/" + }, + { + "name": "Patrik Karisch", + "email": "patrik@karisch.guru", + "homepage": "http://www.karisch.guru" + }, + { + "name": "Romain Biard", + "email": "romain.biard@gmail.com", + "homepage": "https://www.strime.io/" + }, + { + "name": "Jens Hausdorf", + "email": "hello@jens-hausdorf.de", + "homepage": "https://jens-hausdorf.de" + } + ], + "description": "FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg", + "keywords": [ + "audio", + "audio processing", + "avconv", + "avprobe", + "ffmpeg", + "ffprobe", + "video", + "video processing" + ], + "time": "2020-03-29T09:57:10+00:00" + }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2020-03-23T09:12:05+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v5.2.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "fa8f8cab6b65e2d99a118e082935344c5ba8c60d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/fa8f8cab6b65e2d99a118e082935344c5ba8c60d", + "reference": "fa8f8cab6b65e2d99a118e082935344c5ba8c60d", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2020-11-30T17:05:38+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.22.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2021-01-07T16:49:33+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.22.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/dc3063ba22c2a1fd2f45ed856374d79114998f91", + "reference": "dc3063ba22c2a1fd2f45ed856374d79114998f91", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2021-01-07T16:49:33+00:00" + }, + { + "name": "symfony/process", + "version": "v5.2.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "bd8815b8b6705298beaa384f04fabd459c10bedd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/bd8815b8b6705298beaa384f04fabd459c10bedd", + "reference": "bd8815b8b6705298beaa384f04fabd459c10bedd", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.15" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2020-12-08T17:03:37+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/listBDD.py b/listBDD.py new file mode 100755 index 0000000..d023706 --- /dev/null +++ b/listBDD.py @@ -0,0 +1,401 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +#from tmdbv3api import TMDb +from __future__ import print_function +from iso639 import languages +import tmdbv3api +import sys +import os +import locale +from datetime import datetime +import sqlite3 +import argparse +import re +import wget + +class ForeColors: + RED = '\033[31m' + GREEN = '\033[32m' + YELLOW = '\033[33m' + BLUE = '\033[34m' + MAGENTA = '\033[35m' + CYAN = '\033[36m' + LIRED = '\033[91m' + LIGREEN = '\033[92m' + LIYELLOW = '\033[93m' + LIBLUE = '\033[94m' + LIMAGENTA = '\033[95m' + LICYAN = '\033[96m' + END = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + +class BackColors: + RED = '\033[41m' + GREEN = '\033[42m' + YELLOW = '\033[43m' + BLUE = '\033[44m' + MAGENTA = '\033[45m' + CYAN = '\033[46m' + LIRED = '\033[101m' + LIGREEN = '\033[102m' + LIYELLOW = '\033[103m' + LIBLUE = '\033[104m' + LIMAGENTA = '\033[105m' + LICYAN = '\033[106m' + END = '\033[0m' + BOLD = '\033[1m' + UNDERLINE = '\033[4m' + +locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') + +parser = argparse.ArgumentParser() +parser.add_argument("-p", "--purge", action="store_true", help="delete non existing film and saga if empty") +parser.add_argument("-s", "--symbolic", action="store_true", help="use symbolic path") +parser.add_argument("-q", "--quiet", action="store_true", help="quite mode reduce verbosity") +parser.add_argument("-d", "--database", default='bdd.db', help="Database location") +parser.add_argument("path", nargs='?', default='list/', help="defined the directory or the file to add in database") + +args = parser.parse_args() + +path = args.path + +if not args.symbolic: + path = os.path.realpath(path) + +if args.quiet: + print("Quiet mode") + def printr(*args): + pass +else: + def printr(*args): + print(*args) + +bdd = args.database + + +img_url='http://image.tmdb.org/t/p/original/' + +img_dir= '/var/www/html/img' + + +nbFiles = 0 +nbExist = 0 +nbAdd = 0 + +def query_yes_no(question, default="yes"): + """Ask a yes/no question via raw_input() and return their answer. + + "question" is a string that is presented to the user. + "default" is the presumed answer if the user just hits . + It must be "yes" (the default), "no" or None (meaning + an answer is required of the user). + + The "answer" return value is True for "yes" or False for "no". + """ + valid = {"yes": True, "y": True, "ye": True, + "no": False, "n": False} + if default is None: + prompt = " [y/n] " + elif default == "yes": + prompt = " [Y/n] " + elif default == "no": + prompt = " [y/N] " + else: + raise ValueError("invalid default answer: '%s'" % default) + + while True: + sys.stdout.write(question + prompt) + choice = input().lower() + if default is not None and choice == '': + return valid[default] + elif choice in valid: + return valid[choice] + else: + sys.stdout.write("Please respond with 'yes' or 'no' " + "(or 'y' or 'n').\n") + +def browse(path): + + files = [] + files_path = [] + ext = [".mkv", ".avi", ".mp4"] + global nbFiles + + if os.path.isdir(path): + + # r=root, d=directories, f = files + for r, d, f in os.walk(path): + for file in f: + if os.path.splitext(file)[1].lower() in ext: + files_path.append(os.path.join(r, file)) + file = os.path.splitext(file)[0] + files.append(file) + nbFiles+=1 + elif os.path.isfile(path): + if os.path.splitext(path)[1].lower() in ext: + files_path.append(path) + file = os.path.basename(path) + file = os.path.splitext(file)[0] + files.append(file) + + return files, files_path + +def createTable(): + + conn = sqlite3.connect(bdd) + + cursor = conn.cursor() + + cursor.execute(""" + CREATE TABLE IF NOT EXISTS sagas( + id INTEGER PRIMARY KEY UNIQUE NOT NULL, + name TEXT, + poster_path TEXT + ) + """) + + cursor.execute(""" + CREATE TABLE IF NOT EXISTS movies( + id INTEGER PRIMARY KEY UNIQUE NOT NULL, + title TEXT, + release_date DATE, + overview TEXT, + original_language TEXT, + original_title TEXT, + file_name TEXT, + file_path TEXT, + poster_path TEXT, + sagaID INTEGER, + CONSTRAINT movies_sagas_FK FOREIGN KEY (sagaID) REFERENCES sagas(id) + ) + """) + + conn.commit() + + conn.close() + + +def searchMovie(file_name): + + # create an instance of the IMDb class + tmdb = tmdbv3api.TMDb() + m = tmdbv3api.Movie() + + tmdb.language = 'fr' + tmdb.debug = False + tmdb.api_key = '64f8b9bb9ba42cfe74ee0e9da1fa1690' + + year = None + + if re.search(r'\([0-9]*\)', file_name): + + name = (re.findall(r'(.*) \([0-9]*\)', file_name))[0] + year = (re.findall(r'\(([0-9]*)\)', file_name))[0] + + else: + name = file_name + + printr (name) + printr (year) + + movies = m.search(name) + movie = None + + if not movies: + return None + + if year != None: + for n in movies: + if hasattr(n, 'release_date'): + if n.release_date.split('-')[0] == year: + movie = n + break + else: + movie = movies[0] + + return movie + +def add(): + + tmdb = tmdbv3api.TMDb() + m = tmdbv3api.Movie() + + tmdb.language = 'fr' + tmdb.debug = False + tmdb.api_key = '64f8b9bb9ba42cfe74ee0e9da1fa1690' + + global nbAdd + global nbExist + + + conn = sqlite3.connect(bdd) + + cursor = conn.cursor() + + files, files_path = browse(path) + + + for file_name, file_path in zip(files, files_path): + + cursor.execute("""SELECT * FROM movies WHERE file_path=?""", (file_path,)) + + result = cursor.fetchone() + + if result: + print(ForeColors.GREEN + "{} alredy exist for movie {} {}".format(file_path,ForeColors.END,result[1])) + + else: + + printr(file_name) + + movie = searchMovie(file_name) + + if not movie: + print(ForeColors.MAGENTA + '{} Aucun resultat'.format(file_path) + ForeColors.END) + continue + + id = movie.id + title = movie.title + release_date = movie.release_date + overview = movie.overview + original_language = movie.original_language + original_title = movie.original_title + poster_path = movie.poster_path + + printr("Movie : {}".format(title)) + + printr(release_date) + + if not os.path.isdir(img_dir): + os.mkdir(img_dir) + + if poster_path != None: + if not os.path.isfile(img_dir+poster_path): + wget.download(img_url+poster_path, out=img_dir, bar=None) + + detail = m.details(movie.id) + + if detail.belongs_to_collection != None: + sagaID = detail.belongs_to_collection['id'] + sagaNAME = detail.belongs_to_collection['name'] + sagaPATH = detail.belongs_to_collection['poster_path'] + if sagaPATH != None: + if not os.path.isfile(img_dir+sagaPATH): + wget.download(img_url+sagaPATH, out=img_dir, bar=None) + else: + printr("No Saga") + sagaID = 0 + + + cursor.execute("""SELECT * FROM movies WHERE id=?""", (id,)) + + result = cursor.fetchone() + + if result: + print(ForeColors.LIRED + "{} find for Movie {} {} {} and his alredy exist at {}".format(file_path, ForeColors.END, title, ForeColors.LIRED, result[7]) + ForeColors.END) + nbExist+=1 + else: + if detail.belongs_to_collection != None: + cursor.execute("""SELECT 1 FROM sagas WHERE id=?""", (sagaID,)) + + if cursor.fetchone(): + printr("{} alredy exist".format(sagaNAME)) + + else: + cursor.execute("""INSERT INTO sagas VALUES(?, ?, ?)""", (sagaID, sagaNAME, sagaPATH)) + printr("Saga added") + + + cursor.execute("""INSERT INTO movies VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", (id, title, release_date, overview, original_language, original_title, file_name, file_path, poster_path, sagaID)) + print(ForeColors.LIBLUE + "{} find for Movie {} {}".format(file_path, ForeColors.END, title)) + nbAdd+=1 + + + conn.commit() + + printr() + + + #cursor.execute("""SELECT id, title, release_date, overview, original_language, original_title, poster_path FROM movies""") + #for row in cursor: + # print('{0} :\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}'.format(row[0], row[1], row[2], row[3], row[4], row[5], row[6])) + # print() + + conn.close() + + +def purge(): + + delarray = [] + + compt = 0 + + conn = sqlite3.connect(bdd) + + cursor = conn.cursor() + + cursor.execute("SELECT id, title, file_path, poster_path, sagaID FROM movies") + + result = cursor.fetchall() + + for file in result: + if not os.path.isfile(file[2]): + delarray.append(file) + compt+=1 + + for title in delarray: + print(title[1]) + + if compt > 0: + if query_yes_no("Do you want to delete this {} entry".format(compt), "no"): + for title in delarray: + cursor.execute("""DELETE FROM movies WHERE id=?""", (title[0],)) + + if title[4] != 0: + + cursor.execute("""SELECT name FROM sagas WHERE id=?""", (title[4],)) + + sagaNAME = cursor.fetchone()[0] + + cursor.execute("""SELECT 1 FROM movies WHERE sagaID=?""", (title[4],)) + + if cursor.fetchone(): + printr("Found Movie in {} not delete it".format(sagaNAME)) + else: + cursor.execute("""DELETE FROM sagas WHERE id=?""", (title[4],)) + printr("{} deleted".format(sagaNAME)) + + + if query_yes_no("Do you want to delete their images", "yes"): + for title in delarray: + if title[3] != None: + if os.path.isfile(img_dir+title[3]): + print("Del image "+title[3]) + os.remove(img_dir+title[3]) + else: + print("Nothing to purge") + + + conn.commit() + + conn.close() + + + + + +createTable() + +if args.purge == True: + print("Purge mode") + purge() +else: + print("Add mode") + add() + print("Nombre de fichiers : {}".format(nbFiles)) + print("Nombre de fichiers déjà existant : {}".format(nbExist)) + print("Nombre de fichiers ajouter : {}".format(nbAdd)) + + diff --git a/php/DaveRandom_Resume.php b/php/DaveRandom_Resume.php index 865a689..4df22d8 100644 --- a/php/DaveRandom_Resume.php +++ b/php/DaveRandom_Resume.php @@ -2,7 +2,7 @@ namespace DaveRandom\Resume; -require __DIR__ . '/../../vendor/autoload.php'; +require __DIR__ . '../vendor/autoload.php'; include "function.php"; diff --git a/php/function.php b/php/function.php index efd55af..1b90244 100644 --- a/php/function.php +++ b/php/function.php @@ -4,7 +4,7 @@ setlocale (LC_TIME, 'fr_FR.utf8'); $images_folder = '/img'; -$bdd = '/var/www/html/bdd.db'; +$bdd = '../bdd.db'; $output_video_folder = 'vid/'; @@ -58,7 +58,7 @@ function convert($id, $video, $audio) { function MediaInfo($file) { - require '/var/www/html/vendor/autoload.php'; + require '../vendor/autoload.php'; $ffprobe = FFMpeg\FFProbe::create();