diff --git a/imdb_parsen/imdb_top_250_movies.csv b/imdb_parsen/imdb_top_250_movies.csv new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/imdb_parsen/imdb_top_250_movies.csv @@ -0,0 +1 @@ + diff --git a/imdb_parsen/main.py b/imdb_parsen/main.py new file mode 100644 index 0000000..17d9ebf --- /dev/null +++ b/imdb_parsen/main.py @@ -0,0 +1,23 @@ +# print(the_matrix.get('tech')) +from imdb import Cinemagoer + +# create an instance of the Cinemagoer class +ia = Cinemagoer() + +# get a movie +movie = ia.get_movie('0133093') + +# print the names of the directors of the movie +print('Directors:') +for director in movie['directors']: + print(director['name']) + +# print the genres of the movie +print('Genres:') +for genre in movie['genres']: + print(genre) + +# search for a person name +people = ia.search_person('Mel Gibson') +for person in people: + print(person.personID, person['name']) diff --git a/imdb_parsen/test.py b/imdb_parsen/test.py new file mode 100644 index 0000000..541135c --- /dev/null +++ b/imdb_parsen/test.py @@ -0,0 +1,48 @@ +from bs4 import BeautifulSoup +import requests +import re +import pandas as pd + + +# Downloading imdb top 250 movie's data +url = 'http://www.imdb.com/chart/top' +response = requests.get(url) +soup = BeautifulSoup(response.text, "html.parser") +movies = soup.select('td.titleColumn') +crew = [a.attrs.get('title') for a in soup.select('td.titleColumn a')] +ratings = [b.attrs.get('data-value') + for b in soup.select('td.posterColumn span[name=ir]')] + + +# create a empty list for storing +# movie information +list = [] + +# Iterating over movies to extract +# each movie's details +for index in range(0, len(movies)): + + # Separating movie into: 'place', + # 'title', 'year' + movie_string = movies[index].get_text() + movie = (' '.join(movie_string.split()).replace('.', '')) + movie_title = movie[len(str(index))+1:-7] + # year = re.search('\((.*?)\)', movie_string).group(1) + place = movie[:len(str(index))-(len(movie))] + data = {"place": place, + "movie_title": movie_title, + "rating": ratings[index], + # "year": year, + "star_cast": crew[index], + } + list.append(data) + +# printing movie details with its rating. +for movie in list: + print(movie['place'], '-', movie['movie_title'], + 'Starring:', movie['star_cast'], movie['rating']) + + +## .......## +df = pd.DataFrame(list) +df.to_csv('imdb_top_250_movies.csv', index=False) diff --git a/movie-db/__pycache__/moviedb_func.cpython-313.pyc b/movie-db/__pycache__/moviedb_func.cpython-313.pyc index f8aea6a..f058568 100644 Binary files a/movie-db/__pycache__/moviedb_func.cpython-313.pyc and b/movie-db/__pycache__/moviedb_func.cpython-313.pyc differ diff --git a/movie-db/main.py b/movie-db/main.py index f361dda..c47b7b2 100644 --- a/movie-db/main.py +++ b/movie-db/main.py @@ -19,6 +19,7 @@ def add_movie(): data=moviedb_func.all_select(), data_medium=moviedb_func.all_select(what_select="medium"), data_regie=moviedb_func.all_select(what_select="regie"), + data_all=moviedb_func.show_movie_list() ) diff --git a/movie-db/movie_db.db b/movie-db/movie_db.db index b3e9245..cceacad 100644 Binary files a/movie-db/movie_db.db and b/movie-db/movie_db.db differ diff --git a/movie-db/moviedb_func.py b/movie-db/moviedb_func.py index 3fa4921..eedb6f3 100644 --- a/movie-db/moviedb_func.py +++ b/movie-db/moviedb_func.py @@ -158,9 +158,9 @@ def show_movie_list(db_name="movie_db.db"): db = sqlite3.connect(db_name) SELCET_VALUE = pd.read_sql(SQL_PARAM, db) return_list_dict = [] - for id, titel, genre, regie_surname, regie_lastname in zip(SELCET_VALUE["id"], SELCET_VALUE["titel"], SELCET_VALUE["genre"], SELCET_VALUE["regie_surname"], SELCET_VALUE["regie_lastname"]): + for id, titel, genre, regie_surname, regie_lastname, medium in zip(SELCET_VALUE["id"], SELCET_VALUE["titel"], SELCET_VALUE["genre"], SELCET_VALUE["regie_surname"], SELCET_VALUE["regie_lastname"], SELCET_VALUE["medium"]): return_list_dict.append( - {"id": id, "titel": titel, "genre": genre, "regie": regie_surname + " " + regie_lastname}) + {"id": id, "titel": titel, "genre": genre, "regie": regie_surname + " " + regie_lastname, "medium": medium}) return return_list_dict @@ -171,4 +171,5 @@ if __name__ == "__main__": # search_name="DVD", select_from="medium", select_where="medium") add_movie_to_list(movie_name="Schlumpfland", genre_id=1, regie_id=1, medium_id=1) - print(show_movie_list()) + for test in show_movie_list(): + print(test.get("id"), test.get("medium")) diff --git a/movie-db/templates/add_movie.html b/movie-db/templates/add_movie.html index 41c8b40..e93c98d 100644 --- a/movie-db/templates/add_movie.html +++ b/movie-db/templates/add_movie.html @@ -25,7 +25,26 @@   - - +
+ + + + + + + + + + {% for list_all in data_all %} + + + + + + + + {% endfor %} +
IdNameGenreRegieMedium
{{list_all.get("id")}}{{list_all.get("titel")}}{{list_all.get("genre")}}{{list_all.get("regie")}}{{list_all.get("medium")}}
+ {% endblock %} diff --git a/ollama_remote_query/ollama_prompt.py b/ollama_remote_query/ollama_prompt.py new file mode 100755 index 0000000..8ec249b --- /dev/null +++ b/ollama_remote_query/ollama_prompt.py @@ -0,0 +1,37 @@ +#! /usr/bin/env python +from ollama import Client +import datetime +import os + +output_folder = "output" + +if not os.path.exists(output_folder): + os.makedirs(output_folder) + +# Create_Timestamp +now = int(datetime.datetime.now().timestamp()) +# res = int(now.timestamp()) + +# PROMT +prompt = input("Was möchtest du Fragen: ") + +client = Client( + host='http://localhost:11434', + headers={'x-some-header': 'some-value'} +) + +response = client.chat( + model='gemma3n:e2b', + messages=[ + { + 'role': 'user', + 'content': prompt, + }], + stream=True) + +for chunk in response: + print(chunk['message']["content"], end='', flush=True) + with open(str(output_folder + "/ollama_output_" + str(now) + ".md"), "a") as dm: + print(chunk['message']["content"], end='', flush=True, file=dm) + +# with open("test.md", "w") as dm: diff --git a/ollama_remote_query/output/ollama_output_1755524506.md b/ollama_remote_query/output/ollama_output_1755524506.md new file mode 100644 index 0000000..e69d89a --- /dev/null +++ b/ollama_remote_query/output/ollama_output_1755524506.md @@ -0,0 +1,6 @@ +Okay, I'm exiting. Have a good one! + +If you need anything in the future, feel free to ask. 😊 + + + diff --git a/ollama_remote_query/translate_func.py b/ollama_remote_query/translate_func.py new file mode 100644 index 0000000..495b2e3 --- /dev/null +++ b/ollama_remote_query/translate_func.py @@ -0,0 +1,38 @@ +# %% packages +# from langchain_openai import ChatOpenAI +import langchain_ollama +from langchain_core.prompts import ChatPromptTemplate +# from dotenv import load_dotenv +from langchain_core.output_parsers import StrOutputParser +# load_dotenv('.env') + + +def translate_func(select_lang="Germany", target_lang="English", query_trans="prompt"): + if query_trans == "prompt": + query_trans = input("Was soll Übersetzt werden ? ") + # %% set up prompt template + prompt_template = ChatPromptTemplate.from_messages([ + ("system", f"You are an AI assistant that translates { + select_lang} into another language."), + ("user", "Translate this sentence: '{input}' into {target_language}"), + ]) + + # %% model + model = langchain_ollama.llms.OllamaLLM(base_url='http://localhost:11434', model="gemma3n:e2b", + temperature=0) + + # %% chain + chain = prompt_template | model | StrOutputParser() + + # %% invoke chain + res = chain.invoke({"input": query_trans, + "target_language": target_lang}) + print(res) + + # %% + + +if __name__ == "__main__": + select_lang = "Germany" + target_lang = "English" + translate_func(select_lang=target_lang, target_lang=select_lang)