예제 #1
0
    def show_video(self, cat, title, ep, video_page, btn_id, sender):
        original_url = video_spider(video_page)
        if not original_url: return

        try:
            webview = ui.WebView(name=ep)
            webview.right_button_items = [
                ui.ButtonItem('Next',
                              action=functools.partial(self.show_next_video,
                                                       btn_id, webview))
            ]
            webview.frame = (0, 0, 640, 640)

            print('video url\n',
                  self.video_parsers[self.server_id] + original_url)
            webview.load_url(self.video_parsers[self.server_id] + original_url)
            self.app.nav_view.push_view(webview)
        except Exception as e:
            print_msg('Load video page error', e)
        else:
            new_hist = '{};{};{}'.format(cat, title, ep)
            if self.app.hist_list[0] != new_hist:
                self.app.hist_list = [new_hist] + self.app.hist_list

                with open(HISTORY_FILE, 'a', encoding='utf8') as f:
                    f.write(new_hist + '\n')
예제 #2
0
 def title_tapped(self, cat, title):
     try:
         info = self.app.index[cat][title]
     except:
         print_msg('This anime is not found!')
     else:
         detail_view = AnimeDetailView(self.app, title, info)
         self.app.nav_view.push_view(detail_view.view)
예제 #3
0
 def title_tapped(self, selected_title):
     try:
         #selected_title = sender.items[sender.selected_row]['title']
         detail_view = AnimeDetailView(self.app, selected_title,
                                       self.anime_dict[selected_title])
         self.app.nav_view.push_view(detail_view.view)
     except Exception as e:
         print_msg('Failed to load page', e)
예제 #4
0
 def show_next_video(self, btn_id, webviewer, sender):
     try:
         next_btn_id = int(btn_id.strip('btn')) + 1
         next_title = self.view['btn' + str(next_btn_id)].title
         print_msg(next_title, msg_type='success')
     except Exception as e:
         print(e)
     else:
         webviewer.stop()
         self.app.nav_view.pop_view(webviewer)
         self.show_video(self.category, self.anime_title, next_title,
                         self.episodes[next_title],
                         'btn' + str(next_btn_id), sender)
예제 #5
0
 def check_mark(self, sender):
     try:
         if self.is_marked:  #unmark
             sender.image = ui.Image('iob:ios7_star_outline_' +
                                     self.app.icon_size)
             self.app.favorite_dict.pop(self.anime_title)
             console.hud_alert('Unmarked', 'success', 0.5)
         else:  #mark
             sender.image = ui.Image('iob:star_' + self.app.icon_size)
             self.app.favorite_dict[self.anime_title] = self.anime_infos
             console.hud_alert('Marked', 'success', 0.5)
     except Exception as e:
         print_msg('Error!', e)
     else:
         self.app.save_favor()
예제 #6
0
    def search_diag(self, sender):
        keyword = dialogs.input_alert('Search keyword')
        search_index = list(self.app.index.values())

        ret_dict = {}
        for each_cat in search_index:
            for key in each_cat.keys():
                if keyword in key:
                    ret_dict[key] = each_cat[key]

        if not ret_dict:
            print_msg('Not found!')
            return

        tools_table = AnimeTable(self.app, 'Search', ret_dict)
        self.app.nav_view.push_view(tools_table.view)
예제 #7
0
    def load(self):
        self.app.activity_indicator.start()
        try:
            categories_listdatasource = ui.ListDataSource(
                {
                    'title': category_name,
                    'accessory_type': 'disclosure_indicator'
                } for category_name in sorted(self.categories_dict.keys()) +
                ['***Update Cache***'])
            categories_listdatasource.action = self.category_item_tapped
            categories_listdatasource.delete_enabled = False

            self.view.data_source = categories_listdatasource
            self.view.delegate = categories_listdatasource
            self.view.reload()
        except Exception as e:
            print_msg('Failed to load Categories', e)
        finally:
            self.app.activity_indicator.stop()