Esempio n. 1
0
    def testEventMinimal(self):
        day = datetime.datetime(2012, 12, 31)
        parserOptions = ParserOptions()
        channel = Channel(123, 'testchan',
                          'http://media.teleman.pl/logos/m/tvp-1.png')
        event = TelemanEvent(parserOptions, channel, 'simple event',
                             'Movie/Drama', 'movie', None, day,
                             day + datetime.timedelta(days=1), None)

        f = StringIO.StringIO()
        output = XmltvOutput.XmltvOutput()
        output.Init(f)
        guide = [event]
        output.SaveGuide(day, guide)
        output.SaveGuideChannels()
        output.Finish()
        expected = """
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE tv SYSTEM "xmltv.dtd">
<tv generator-info-name="epguide generator">
  <programme start="20121231000000 +0200" stop="20130101000000 +0200" channel="123">
    <title>simple event</title>
    <category language="en">Movie/Drama</category>
    <category language="pl">movie</category>
  </programme>
  <channel id="123"><display-name lang="pl">testchan</display-name><icon src="http://media.teleman.pl/logos/m/tvp-1.png"/></channel>
</tv>
""".lstrip()
        self.assertEqual(f.getvalue(), expected)
Esempio n. 2
0
    def testEvent(self):
        channel = Channel(123, 'testchan', 'http://media.teleman.pl/logos/m/tvp-1.png')
        parserOptions = ParserOptions()
        event = TelemanEvent(parserOptions, channel, 'simple event', 'Movie/Drama', 'movie',
                             'this is description for an event', datetime.date.today(), datetime.date.today() + datetime.timedelta(days=1),
                             None)

        f = StringIO.StringIO()
        output = TxtOutput.TxtOutput()
        output.Init(f)
        guide = [event]
        day = datetime.datetime(2012, 12, 31)
        output.SaveGuide(day, guide)
        output.Finish()
        expected = u"""
Program testchan na dzień: 2012-12-31
--------------------------------------------

 00:00 00:00 simple event |  |  | Movie/Drama
             this is description for an event
"""
        actual = f.getvalue()
        print("actual: " + actual)
        print("expected: " + expected)
        self.assertEqual(actual, expected)
Esempio n. 3
0
    def create_event(self, event_element, channel, event_date):
        #<li class="cat-ser with-photo" id="prog7532796">
        #  <a href="/tv/Faceci-Do-Wziecia-Szkola-Rodzenia-41-988883">
        #    <img width="100" height="63" class="photo" alt="zdjęcie" src="http://media.teleman.pl/photos/crop-100x63/Faceci-Do-Wziecia.jpeg">
        #  </a>
        #  <em>6:00</em>
        #  <div class="detail">
        #    <a href="/tv/Faceci-Do-Wziecia-Szkola-Rodzenia-41-988883">Faceci do wzięcia: Szkoła rodzenia (41)</a>
        #    <p class="genre">serial komediowy</p>
        #    <p>Dziennikarz Wiktor jest bałaganiarzem. Fotograf Roman to klasyczny pedant. Obaj, porzuceni przez żony, zamieszkują w jednym mieszkaniu.</p>
        #  </div>
        #</li>
        prog_id = event_element.get("id")
        if prog_id:
            title = self.get_texts(event_element, 'div[@class="detail"]/a')
            self.log.debug("  title: '" + title.encode('utf8') + "'")
            url = self.get_attr(event_element, 'div[@class="detail"]/a',
                                "href")

            time_start_string = self.get_texts(event_element, 'em')
            datetime_start_string = "%s %s" % (event_date.strftime("%Y-%m-%d"),
                                               time_start_string)
            time_start_struct = time.strptime(datetime_start_string,
                                              '%Y-%m-%d %H:%M')
            time_start = datetime.datetime.fromtimestamp(
                time.mktime(time_start_struct))

            time_end = time_start  #TODO
            category = self.get_texts(
                event_element, 'div[@class="detail"]/p[@class="genre"]')
            summary = self.get_texts(event_element,
                                     'div[@class="detail"]/p[@class="genre"]')
            #http://media.teleman.pl/photos/crop-100x63/Barwy-Szczescia_1.jpeg
            photo_url = self.get_attr(event_element, 'a/img', "src")
            #http://media.teleman.pl/photos/470x265/Barwy-Szczescia_1.jpeg
            photo_url = photo_url.replace("crop-100x63", "470x265")

            class_attrs = event_element.get("class").split()
            main_category_class = next(
                (c for c in class_attrs if c.startswith("cat-")), None)
            main_category = self.category_classes_to_main_category.get(
                main_category_class, "")
            self.log.debug("main_category_class:" + main_category_class +
                           " main_category:" + main_category)

            self.log.debug("event_element: " + str(channel) + " " +
                           str(time_start) + " " + str(time_end) + " " +
                           title.encode('utf8') + " " + " " +
                           main_category.encode('utf8') + " " +
                           category.encode('utf8') + " " + url)
            event = TelemanEvent(self.parser_options, channel, title,
                                 main_category, category, summary, time_start,
                                 time_end, url, None, photo_url, prog_id)

            return event
        else:
            return None
Esempio n. 4
0
    def testEventFull(self):
        day = datetime.datetime(2012, 12, 31)
        channel = Channel(123, 'testchan',
                          'http://media.teleman.pl/logos/m/tvp-1.png')
        parserOptions = ParserOptions(split_title=True)
        event = TelemanEvent(parserOptions, channel,
                             'simple event: subtitle for an event (2/3)',
                             'Movie/Drama', 'movie',
                             'this is description for an event', day,
                             day + datetime.timedelta(days=1), None)

        f = StringIO.StringIO()
        output = XmltvOutput.XmltvOutput()
        output.Init(f)
        guide = [event]
        output.SaveGuide(day, guide)
        output.SaveGuideChannels()
        output.Finish()
        expected = """
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE tv SYSTEM "xmltv.dtd">
<tv generator-info-name="epguide generator">
  <programme start="20121231000000 +0200" stop="20130101000000 +0200" channel="123">
    <title>simple event</title>
    <sub-title>subtitle for an event</sub-title>
    <desc><![CDATA[this is description for an event]]></desc>
    <category language="en">Movie/Drama</category>
    <category language="pl">movie</category>
    <episode-num system="onscreen">2/3</episode-num>
  </programme>
  <channel id="123"><display-name lang="pl">testchan</display-name><icon src="http://media.teleman.pl/logos/m/tvp-1.png"/></channel>
</tv>
""".lstrip()
        actual = f.getvalue()
        print("actual: " + actual)
        print("expected: " + expected)
        self.assertEqual(actual, expected)
    def testShowWithSubtitleWithDetails(self):
        imdb_url = u"x"
        imdb_rank = u"x"
        imdb = Imdb(imdb_url, imdb_rank)
        filmweb_url = u"x"
        filmweb_rank = u"x"
        filmweb = Imdb(filmweb_url, filmweb_rank)
        photo_url = u"x"
        channel = Channel('x', 'x', "x")

        title = u'Rodzinka.pl: Zachcianki (80)'
        category = 'serial komediowy'
        desc = 'One line summary.'

        primary_title = u'Rodzinka.pl: Zachcianki (80)'
        secondary_title = None
        original_title = None
        genre = u"serial komediowy"
        country = u"Polska"
        year = u"2013"
        pg = ParentalRating(u"od 12 lat", 12)
        description = u"Long description"
        details = TelemanEventDetails(primary_title, secondary_title,
                                      description, original_title, year,
                                      country, genre, imdb, filmweb, photo_url,
                                      pg)

        main_category = 'Show/Game show'
        time_start = '2013-01-02 02:10:00'
        time_end = '2013-01-02 03:50:00'
        url = None

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u'Rodzinka.pl: Zachcianki (80)')  # with original title and year
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Rodzinka.pl: Zachcianki (80)')

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         u'Rodzinka.pl')  # with original title and year
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")
        self.assertEqual(event.get_filename(), u'Rodzinka.pl (80) Zachcianki')

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(), u'Rodzinka.pl')  # with year
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")
        self.assertEqual(event.get_filename(), u'Rodzinka.pl (80) Zachcianki')

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         u'Rodzinka.pl')  # with original title
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(), u'Rodzinka.pl')  # nothing
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u'Rodzinka.pl [od 12 lat]')  # with original title, year and age
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=12)
        self.assertEqual(event.get_title(),
                         u'Rodzinka.pl [od 12 lat]')  # with year and age
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=12)
        self.assertEqual(
            event.get_title(),
            u'Rodzinka.pl [od 12 lat]')  # with original title and age
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=12)
        self.assertEqual(event.get_title(),
                         u'Rodzinka.pl [od 12 lat]')  # with age
        self.assertEqual(event.get_subtitle(), "Zachcianki")
        self.assertEqual(event.get_episode_num(), "80")

        self.assertEqual(event.get_description(),
                         u'One line summary.Long description')
    def testMovie(self):
        imdb_url = u"x"
        imdb_rank = u"x"
        imdb = Imdb(imdb_url, imdb_rank)
        filmweb_url = u"x"
        filmweb_rank = u"x"
        filmweb = Imdb(filmweb_url, filmweb_rank)
        photo_url = u"x"
        channel = Channel('x', 'x', "x")

        primary_title = 'Liberator 2'
        secondary_title = ''
        description = u"description"
        original_title = u"original title"
        year = u"2009"
        country = u"USA"
        genre = u"FILM GANGSTERSKI"
        pg = ParentalRating(u"od 16 lat", 16)
        details = TelemanEventDetails(primary_title, secondary_title, description, original_title, year, country, genre, imdb, filmweb, photo_url, pg)
        
        title = 'Megahit: Liberator 2'
        main_category = 'Movie/Drama'
        category = 'film sensacyjny, USA 1995'
        desc = 'summary'
        time_start = '2013-01-02 02:10:00'
        time_end = '2013-01-02 03:50:00'
        url = None

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = True, add_age_rating_to_title = 16)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), u"original title (2009) - Liberator 2 [od 16 lat] [Megahit]")
        self.assertEqual(event.get_filename(), u"original title (2009) - Liberator 2 [od 16 lat] [Megahit]")

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = True, add_age_rating_to_title = 16)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), "Liberator 2 [od 16 lat] [Megahit]")
        self.assertEqual(event.get_filename(), u"Liberator 2 [od 16 lat] [Megahit]")

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = False, add_age_rating_to_title = 16)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), u"original title - Liberator 2 [od 16 lat] [Megahit]")
        self.assertEqual(event.get_filename(), u"original title - Liberator 2 [od 16 lat] [Megahit]")

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = False, add_age_rating_to_title = 16)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), "Liberator 2 [od 16 lat] [Megahit]")
        self.assertEqual(event.get_filename(), u"Liberator 2 [od 16 lat] [Megahit]")


        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = True, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), u"original title (2009) - Liberator 2 [Megahit]")
        self.assertEqual(event.get_filename(), u"original title (2009) - Liberator 2 [Megahit]")

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = True, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), "Liberator 2 [Megahit]")
        self.assertEqual(event.get_filename(), u"Liberator 2 [Megahit]")

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = False, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), u"original title - Liberator 2 [Megahit]")
        self.assertEqual(event.get_filename(), u"original title - Liberator 2 [Megahit]")

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = False, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_title(), "Liberator 2 [Megahit]")
        self.assertEqual(event.get_filename(), u"Liberator 2 [Megahit]")


        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = False, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=details)
        self.assertEqual(event.get_description(), u'summarydescription\nTytul oryginalny:original title')
Esempio n. 7
0
    def testShowWithEpisodeNumWithoutSubtitleWithoutDetails(self):
        channel = Channel('x','x',"x")

        title = u'Barwy szczęścia (948)'
        category = 'serial obyczajowy'
        desc = 'One line summary.'
        
        main_category = 'Show/Game show'
        time_start = '2013-01-02 02:10:00'
        time_end = '2013-01-02 03:50:00'
        url = None

        parser_options = ParserOptions(split_title = False, add_original_title_to_title = True, add_year_to_title = True, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)') # with original title and year
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')
        
         
        parser_options = ParserOptions(split_title = False, add_original_title_to_title = False, add_year_to_title = True, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)') # with year 
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        
        parser_options = ParserOptions(split_title = False, add_original_title_to_title = True, add_year_to_title = False, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)') # with original title 
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = False, add_original_title_to_title = False, add_year_to_title = False, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)')# nothing
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')


        parser_options = ParserOptions(split_title = False, add_original_title_to_title = True, add_year_to_title = True, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)')# with original title, year and age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = False, add_original_title_to_title = False, add_year_to_title = True, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)')# with year and age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = False, add_original_title_to_title = True, add_year_to_title = False, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)') # with original title and age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = False, add_original_title_to_title = False, add_year_to_title = False, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia (948)') # with age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), None)
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')




        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = True, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia') # with original title and year
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')
        
         
        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = True, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia') # with year 
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        
        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = False, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia') # with original title 
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = False, add_age_rating_to_title = 18)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia')# nothing
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')


        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = True, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia')# with original title, year and age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = True, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia')# with year and age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = True, add_year_to_title = False, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia') # with original title and age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        parser_options = ParserOptions(split_title = True, add_original_title_to_title = False, add_year_to_title = False, add_age_rating_to_title = 12)
        event = TelemanEvent(parser_options, channel, title, main_category, category, desc, time_start, time_end, url, details=None)
        self.assertEqual(event.get_title(), u'Barwy szczęścia') # with age
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_episode_num(), "948")
        self.assertEqual(event.get_filename(), u'Barwy szczęścia (948)')

        
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_description(), "One line summary.")
Esempio n. 8
0
    def testShow3(self):
        imdb_url = u"x"
        imdb_rank = u"x"
        imdb = Imdb(imdb_url, imdb_rank)
        filmweb_url = u"x"
        filmweb_rank = u"x"
        filmweb = Imdb(filmweb_url, filmweb_rank)
        photo_url = u"x"
        channel = Channel('x', 'x', "x")

        title = u'Na linii strzału 2 (15)'
        category = 'serial sensacyjny'
        desc = 'One line summary.'

        primary_title = 'Na linii strzału'
        secondary_title = 'sezon 2 odc. 15'
        original_title = "In Plain Sight: In My Humboldt Opinion"
        genre = u"serial sensacyjny"
        country = u"USA"
        year = u"2009"
        pg = ParentalRating(u"od 16 lat", 16)
        description = u"Long description"
        details = TelemanEventDetails(primary_title, secondary_title,
                                      description, original_title, year,
                                      country, genre, imdb, filmweb, photo_url,
                                      pg)

        main_category = 'Show/Game show'
        time_start = '2013-01-02 02:10:00'
        time_end = '2013-01-02 03:50:00'
        url = None
        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(
        ), u'In Plain Sight: In My Humboldt Opinion - Na linii strza\u0142u 2 (15)'
                         )  # with original title and year

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         u'Na linii strza\u0142u 2 (15)')  # with year

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u'In Plain Sight: In My Humboldt Opinion - Na linii strzału 2 (15)'
        )  # with original title

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         u'Na linii strzału 2 (15)')  # nothing

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(
        ), u'In Plain Sight: In My Humboldt Opinion - Na linii strzału 2 (15) [od 16 lat]'
                         )  # with original title, year and age

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u'Na linii strzału 2 (15) [od 16 lat]')  # with year and age

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(
        ), u'In Plain Sight: In My Humboldt Opinion - Na linii strzału 2 (15) [od 16 lat]'
                         )  # with original title and age

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         u'Na linii strzału 2 (15) [od 16 lat]')  # with age

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(
            event.get_description(),
            "One line summary.Long description\nTytul oryginalny:In Plain Sight: In My Humboldt Opinion"
        )
    def testShowWithoutEpisodeNumWithoutSubtitleWithoutDetails(self):
        channel = Channel('x', 'x', "x")

        title = u'Uwaga'
        category = 'magazyn reporterów'
        desc = 'One line summary.'

        main_category = 'Show/Game show'
        time_start = '2013-01-02 02:10:00'
        time_end = '2013-01-02 03:50:00'
        url = None

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(),
                         u'Uwaga')  # with original title and year

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(), u'Uwaga')  # with year

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(), u'Uwaga')  # with original title

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(), u'Uwaga')  # nothing

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(),
                         u'Uwaga')  # with original title, year and age

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(), u'Uwaga')  # with year and age

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(),
                         u'Uwaga')  # with original title and age

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=12)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=None)
        self.assertEqual(event.get_title(), u'Uwaga')  # with age

        self.assertEqual(event.get_subtitle(), None)
        self.assertEqual(event.get_description(), "One line summary.")
    def testMovie(self):
        imdb_url = u"x"
        imdb_rank = u"x"
        imdb = Imdb(imdb_url, imdb_rank)
        filmweb_url = u"x"
        filmweb_rank = u"x"
        filmweb = Imdb(filmweb_url, filmweb_rank)
        photo_url = u"x"
        channel = Channel('x', 'x', "x")

        primary_title = 'U Pana Boga za piecem'
        secondary_title = ""
        description = u"description"
        original_title = ""
        year = u"1998"
        country = u"Polska"
        genre = u"KOMEDIA"
        pg = ParentalRating(u"od 16 lat", 16)
        details = TelemanEventDetails(primary_title, secondary_title,
                                      description, original_title, year,
                                      country, genre, imdb, filmweb, photo_url,
                                      pg)

        title = 'Wakacyjny hit Jedynki: U Pana Boga za piecem'
        main_category = 'Movie/Drama'
        category = 'komedia, Polska 1998'
        desc = 'summary'
        time_start = '2013-01-02 02:10:00'
        time_end = '2013-01-02 03:50:00'
        url = None

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=99)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         u"Wakacyjny hit Jedynki: U Pana Boga za piecem")
        self.assertEqual(event.get_filename(),
                         u"Wakacyjny hit Jedynki: U Pana Boga za piecem")

        parser_options = ParserOptions(split_title=False,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=16)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u"Wakacyjny hit Jedynki: U Pana Boga za piecem (1998) [od 16 lat]")
        self.assertEqual(
            event.get_filename(),
            u"Wakacyjny hit Jedynki: U Pana Boga za piecem (1998) [od 16 lat]")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=16)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u"U Pana Boga za piecem (1998) [od 16 lat] [Wakacyjny hit Jedynki]"
        )
        self.assertEqual(
            event.get_filename(),
            u"U Pana Boga za piecem (1998) [od 16 lat] [Wakacyjny hit Jedynki]"
        )

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=16)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u"U Pana Boga za piecem (1998) [od 16 lat] [Wakacyjny hit Jedynki]"
        )
        self.assertEqual(
            event.get_filename(),
            u"U Pana Boga za piecem (1998) [od 16 lat] [Wakacyjny hit Jedynki]"
        )

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=16)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u"U Pana Boga za piecem [od 16 lat] [Wakacyjny hit Jedynki]")
        self.assertEqual(
            event.get_filename(),
            u"U Pana Boga za piecem [od 16 lat] [Wakacyjny hit Jedynki]")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=16)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            "U Pana Boga za piecem [od 16 lat] [Wakacyjny hit Jedynki]")
        self.assertEqual(
            event.get_filename(),
            u"U Pana Boga za piecem [od 16 lat] [Wakacyjny hit Jedynki]")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            u"U Pana Boga za piecem (1998) [Wakacyjny hit Jedynki]")
        self.assertEqual(
            event.get_filename(),
            u"U Pana Boga za piecem (1998) [Wakacyjny hit Jedynki]")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=True,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(
            event.get_title(),
            "U Pana Boga za piecem (1998) [Wakacyjny hit Jedynki]")
        self.assertEqual(
            event.get_filename(),
            u"U Pana Boga za piecem (1998) [Wakacyjny hit Jedynki]")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=True,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         u"U Pana Boga za piecem [Wakacyjny hit Jedynki]")
        self.assertEqual(event.get_filename(),
                         u"U Pana Boga za piecem [Wakacyjny hit Jedynki]")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_title(),
                         "U Pana Boga za piecem [Wakacyjny hit Jedynki]")
        self.assertEqual(event.get_filename(),
                         u"U Pana Boga za piecem [Wakacyjny hit Jedynki]")

        parser_options = ParserOptions(split_title=True,
                                       add_original_title_to_title=False,
                                       add_year_to_title=False,
                                       add_age_rating_to_title=18)
        event = TelemanEvent(parser_options,
                             channel,
                             title,
                             main_category,
                             category,
                             desc,
                             time_start,
                             time_end,
                             url,
                             details=details)
        self.assertEqual(event.get_description(), u'summarydescription')