56 lines
1.3 KiB
Python
56 lines
1.3 KiB
Python
# -*- coding:utf-8 -*-
|
|
|
|
import os
|
|
from utils.SQLiteDB import SQLiteDB
|
|
from utils.MySqlUtil import MySqlUtil
|
|
|
|
|
|
def get_config():
|
|
mode= os.environ.get('mode1',1)
|
|
if mode==1:
|
|
return 'sqlite'
|
|
else:
|
|
return 'mysql'
|
|
|
|
def get_movie_list():
|
|
if get_config()=='sqlite':
|
|
db = SQLiteDB()
|
|
db.connect()
|
|
movie_list = db.get_undownloaded()
|
|
db.close()
|
|
return movie_list
|
|
else:
|
|
|
|
db = MySqlUtil('movies')
|
|
movie_list = db.get_all('select * from movies where is_downloaded=0')
|
|
return movie_list
|
|
|
|
|
|
def movie_options(movie_id):
|
|
if get_config()=='sqlite':
|
|
db = SQLiteDB()
|
|
db.connect()
|
|
result=db.mark_downloaded(movie_id)
|
|
db.close()
|
|
return result
|
|
else:
|
|
|
|
db = MySqlUtil('movies')
|
|
movie_list = db.get_all('select * from movies where is_downloaded=0')
|
|
return movie_list
|
|
|
|
def movie_add(movie_name,movie_path):
|
|
if get_config()=='sqlite':
|
|
db = SQLiteDB()
|
|
db.connect()
|
|
result=db.insert_movie(movie_name,movie_path)
|
|
db.close()
|
|
return result
|
|
else:
|
|
|
|
db = MySqlUtil('movies')
|
|
movie_list = db.get_all('select * from movies where is_downloaded=0')
|
|
return movie_list
|
|
|
|
if __name__ == '__main__':
|
|
print(get_movie_list()) |