コード例 #1
0
ファイル: views.py プロジェクト: programistka/movie42night
def add(request):
    if request.method == "POST":
        user = User.objects.get(email='*****@*****.**')
        form = MovieForm(request.POST)
        if form.is_valid():
            # get filmweb information if exists
            # check if the movie with such name and release date exists - if so print the message
            # if not add the item to the database
            title = request.POST['title']
            fw = Filmweb()
            movies = fw.search(title)
            post = form.save(commit=False)
            post.user = user
            post.save()
            movie = Movie.objects.get(id=post.id)
            movie_info = movies[0].get_info()
            date = movie_info['premiere'].split('-')

            Details.objects.create(
                movie=movie,
                description_from_filmweb=movie_info['description_short'],
                rating_from_filmweb=movie_info['rate'],
                year=date[0])
            context = {'movie_desc': movie_info['description_short']}
            return render(request, 'movies42night/getfilmwebinformation.html',
                          context)
    else:
        form = MovieForm()
    return render(request, 'movies42night/add.html', {'form': form})
コード例 #2
0
ファイル: filmweb_watchlist.py プロジェクト: cash2one/flexget
    def on_task_input(self, task, config):
        type = translate_type(config['type'])

        log.verbose('Retrieving filmweb watch list for user: %s',
                    config['login'])

        fw = FilmwebAPI()
        log.verbose('Logging as %s', config['login'])

        try:
            fw.login(str(config['login']), str(config['password']))
        except RequestFailed as error:
            raise plugin.PluginError(
                'Authentication request failed, reason %s' % str(error))

        user = LoggedUser(fw)

        try:
            watch_list = user.get_want_to_see()
        except RequestFailed as error:
            raise plugin.PluginError('Fetching watch list failed, reason %s' %
                                     str(error))

        log.verbose('Filmweb list contains %s items', len(watch_list))

        entries = []
        for item in watch_list:
            if item['level'] < config['min_star']:
                continue

            if item['film'].type != type:
                continue

            item_info = item['film'].get_info()

            entry = Entry()
            entry['title'] = item_info['name_org'] or item_info['name']
            entry['title'] += ' (%s)' % item_info['year']
            entry['year'] = item_info['year']
            entry['url'] = item['film'].url
            entry['filmweb_type'] = item_info['type']
            entry['filmweb_id'] = item['film'].uid

            log.debug('Created entry %s', entry)

            entries.append(entry)

        return entries
def kino_odra_scraper():
    """
    This is a scraper for movie titles which premiere in Kino Odra
    :return: Dictionary where:
                    keys = movie title
                    values= {
                            'link': full_link,
                            'duration': duration,
                            'time_of_spectacles': [time_of_spectacles,]
                            }
    """
    url = "http://kultura.olawa.pl/kino/"
    headers = {'User-Agent': 'Mozilla/5.0'}
    request = Request(url, headers=headers)
    html = urlopen(request).read()
    soup = BeautifulSoup(html, 'html.parser')
    results = soup.find_all('div', class_='movie-info-container')
    returned_dict = {}
    for result in results:  # iterating throught movies
        time_of_spectacles = []  # this is reset for each new movie
        link = result.a['href']
        title = result.a.text
        returned_dict[result.a.text] = result.a['href']
        duration = result.find('span',
                               class_='movie-time').text.lstrip().rstrip('\'')
        tmp_time_of_spctcl = result.find_all('span', class_='movie-hour')
        fw = Filmweb()
        try:
            filmweb_score = fw.search(title)[0].get_info()['rate']
        except ValueError:
            filmweb_score = 0
        for one_tmp_time in tmp_time_of_spctcl:
            hours = int(one_tmp_time.text[:2])
            minutes = int(one_tmp_time.text[3:])
            x = timezone.now().replace(hour=hours,
                                       minute=minutes,
                                       second=0,
                                       microsecond=0)
            time_of_spectacles.append(x)
        returned_dict[title] = {
            'link': link,
            'duration': duration,
            'time_of_spectacles': time_of_spectacles,
            'filmweb_score': filmweb_score
        }
    return returned_dict
コード例 #4
0
    def on_task_input(self, task, config):
        type = translate_type(config['type'])

        log.verbose('Retrieving filmweb watch list for user: %s', config['login'])

        fw = FilmwebAPI()
        log.verbose('Logging as %s', config['login'])

        try:
            fw.login(str(config['login']), str(config['password']))
        except RequestFailed as error:
            raise plugin.PluginError('Authentication request failed, reason %s' % str(error))

        user = LoggedUser(fw)

        try:
            watch_list = user.get_want_to_see()
        except RequestFailed as error:
            raise plugin.PluginError('Fetching watch list failed, reason %s' % str(error))

        log.verbose('Filmweb list contains %s items', len(watch_list))

        entries = []
        for item in watch_list:
            if item['level'] < config['min_star']:
                continue

            if item['film'].type != type:
                continue

            item_info = item['film'].get_info()

            entry = Entry()
            entry['title'] = item_info['name_org'] or item_info['name']
            entry['title'] += ' (%s)' % item_info['year']
            entry['year'] = item_info['year']
            entry['url'] = item['film'].url
            entry['filmweb_type'] = item_info['type']
            entry['filmweb_id'] = item['film'].uid

            log.debug('Created entry %s', entry)

            entries.append(entry)

        return entries
コード例 #5
0
class FilmwebService:
    def __init__(self):
        self.filmweb = Filmweb()

    def get_best_movie(self):
        return self.filmweb.get_popular_films()[0].url

    def get_movie_poster(self, movie_name):
        movie = filter(self.filmweb.search(movie_name), Film)[0]
        return movie.get_poster()

    def known_for(self, actor_name):
        person = self.filmweb.search(actor_name)[0]
        return person.get_info()['film_known_for']

    def get_actor_photo(self, actor_name):
        person = filter(self.filmweb.search(actor_name), Person)[0]
        return person.get_poster()
コード例 #6
0
ファイル: views.py プロジェクト: programistka/movie42night
def get_filmweb_information(request, title):
    fw = Filmweb()
    movies = fw.search_movie(title)
    context = {'movie_desc': movies[0]['desc']}
    return render(request, 'movies42night/getfilmwebinformation.html', context)
コード例 #7
0
 def __init__(self):
     self.filmweb = Filmweb()
コード例 #8
0
#-*- coding: utf-8 -*-
##!/usr/bin/env python
from filmweb.filmweb import Filmweb
import sys, os
import subprocess
import feedparser
import time
reload(sys)
sys.setdefaultencoding('utf-8')

atrybuty = sys.argv
numer = atrybuty[1]
numer = int(numer)

d = feedparser.parse('https://yts.ag/rss/0/720p/all/0')
fw = Filmweb()
post = d.entries[numer]
post.title = post.title.replace("[720p]", "")

#subprocess.call(["/home/pi/speech.sh", introMessage])

if len(atrybuty) == 3:
    #subprocess.call(["/home/pi/speech.sh", "Nie znalazłam miejsca docelowego"])
    link = d.entries[numer]
    link2 = link.enclosures[0]['href']
    #print link2
    os.system('wget -O "/home/pi/torrenty/' + post.title + '.torrent" ' +
              link2)
    #subprocess.call(["/home/pi/speech.sh", "Torrent został ściągnięty"])
    quit()
def go_kino_scraper():
    """
    This is a scraper for movie titles which premiere in GO!Kino
    :return: Dictionary where:
                    keys = movie title
                    values= {
                            'link': full_link,
                            'duration': duration,
                            'time_of_spectacles': [time_of_spectacles <----datetime object]
                            }
    """
    pattern1 = re.compile(r'\d{2}|\d{3}')

    # options = Options()
    # options.headless = True
    # driver = webdriver.Firefox(options=options)
    #                            #executable_path=r'C:\Users\gora-pc\AppData\Local\Programs\Python\Python38-32\Scripts\geckodriver.exe')

    chrome_options = webdriver.ChromeOptions()
    chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--disable-dev-shm-usage")
    chrome_options.add_argument("--no-sandbox")
    driver = webdriver.Chrome(
        executable_path=os.environ.get("CHROMEDRIVER_PATH"),
        chrome_options=chrome_options)

    session = HTMLSession()
    url = "https://gokino.pl/olawa/repertuar/"
    driver.get(url)
    html = driver.page_source
    soup = BeautifulSoup(html, 'html.parser')
    results = soup.find_all('div', class_='item ng-scope')
    returned_dict = {}
    for result in results:
        first_container = result.find(
            'div', class_='col-xs-12 col-md-8 hidden-md-down')
        second_container = result.find(
            'div', class_='col-md-4 hidden-sm-down hours text-xs-center')
        title = first_container.h4.text
        link = 'https://gokino.pl' + first_container.a['href']
        duration_bad_format = result.find(
            'p', class_='ng-binding').text.split('\n')[0]
        # this returns long string separated with \n. 0 element is duration
        if pattern1.search(duration_bad_format) is not None:
            duration = int(pattern1.search(duration_bad_format).group())
        else:
            duration = 0
        spectacles = second_container.find_all('div',
                                               class_='col-md-3 ng-scope')
        time_of_spectacles = []
        fw = Filmweb()
        try:
            filmweb_score = fw.search(title)[0].get_info()['rate']
        except ValueError:
            filmweb_score = 0
        for spec in spectacles:
            hours = int(spec.text.lstrip('\n').rstrip()[:2])
            minutes = int(spec.text.lstrip('\n').rstrip()[3:])
            x = timezone.now().replace(hour=hours,
                                       minute=minutes,
                                       second=0,
                                       microsecond=0)
            time_of_spectacles.append(x)
        returned_dict[title] = {
            'link': link,
            'duration': duration,
            'time_of_spectacles': time_of_spectacles,
            'filmweb_score': filmweb_score
        }
    driver.close()
    return returned_dict
コード例 #10
0
from filmweb.filmweb import Filmweb

fw = Filmweb()
items = fw.search('Jak działa jamniczek')
item = items[0]  # grab first result
info = item.get_info()  # fetch more info
print('Title: {} ({}) Rate: {} ({} votes) Description: {}'.format(
    item.name, item.year, item.rate, item.votes, info['description_short']))
コード例 #11
0
SHOWMAX_API_URL = "http://api.showmax.com/v36.0/website/catalogue/assets?content_country=PL&lang=pol&num=60&subscription_status=full&start="

config = configparser.ConfigParser()
config.read('config.ini')

DB_FILE = config['Config']['DatabaseFile']
POST_TWEETS = config['Config']['PostTweets']

APP_KEY = config['Config']['AppKey']
APP_SECRET = config['Config']['AppSecret']
OAUTH_TOKEN = config['Config']['OAuthToken']
OAUTH_TOKEN_SECRET = config['Config']['OAuthTokenSecret']

current_date = time.strftime("%d-%m-%Y")

fw = Filmweb()


def getRating(item):
    item_title = item['title']
    item_year = str(item['year'])

    items = fw.search(item_title + ' ' + item_year)
    for elem in items:
        elem_title = elem.name
        if SequenceMatcher(None, elem_title, item_title).ratio() > 0.70:
            elem.get_info()
            #print ('Showmax: ' + item_title + ' ' + item_year + ' --- ' + elem_title + ' ' + str(elem.year) + ' ' + str(elem.rate))
            if (abs(int(elem.year) - int(item_year)) < 2):
                return round(elem.rate, 1)