54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
import opml
|
|
# import sqlalchemy as db
|
|
import database as db
|
|
|
|
userID = None
|
|
|
|
def podcastImport (userID):
|
|
print(userID)
|
|
podcasts = db.sql.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
|
|
|
|
outline = opml.parse("podcast_republic_podcasts.opml")
|
|
x = len(outline)
|
|
y=0
|
|
|
|
while y < x:
|
|
title = outline[y].title
|
|
url = outline[y].xmlUrl
|
|
artwork = outline[y].pr_artwork
|
|
desc = outline[y].pr_desc
|
|
query = """insert into podcasts""""(userID, title, URL, desc, artworkURL values (""" + userID + """,""" + title + """,""" + url + """,""" + desc + """,""" + artwork + """)"""
|
|
|
|
# print(str(query))
|
|
db.con.execute(query)
|
|
y=y+1
|
|
|
|
|
|
def login():
|
|
username = 'Dan'
|
|
password = 'password'
|
|
|
|
|
|
user = db.sql.Table('Users', db.metadata, autoload=True, autoload_with=db.engine)
|
|
|
|
query = db.sql.text(""" select userID from Users where username = \"""" + username+"""\"""")
|
|
result = db.con.execute(query).fetchone()
|
|
|
|
print(result[0])
|
|
|
|
return result[0]
|
|
|
|
|
|
while True:
|
|
print("user " + str(userID))
|
|
|
|
print("1. Login \n 2. Upload")
|
|
val = input(">>>")
|
|
if val == "1":
|
|
userID = login()
|
|
elif val == "2":
|
|
if userID is None or userID == '':
|
|
print("Please login first")
|
|
else:
|
|
podcastImport(userID)
|