def __update_db_3(db): current_path = Settings.get().path db.create_tables([Storage]) Storage.create(path=current_path, default=True) Settings.update(path="NOT_USED").execute() Settings.update(version=3).execute()
def __on_no_media_folder_changed(self, sender): """ Get's called when the user changes the audiobook location from the no media screen. Now we want to do a first scan instead of a rebase. """ location = self.no_media_file_chooser.get_file().get_path() external = self.external_switch.get_active() Storage.delete().where(Storage.path != "").execute() Storage.create(path=location, default=True, external=external) self.main_stack.props.visible_child_name = "import" self.scan(None, True) self.settings._init_storage() self.fs_monitor.init_offline_mode()
def __on_add_storage_clicked(self, widget): """ Add a new storage selector to the ui. """ db_obj = Storage.create(path="") self.storage_list_box.add( StorageListBoxRow(self, db_obj.id, "", False, False))
def do_activate(self): main_window_builder = self.ui.get_builder() self.app_controller = AppController(self, main_window_builder, self.ui) self.ui.activate(self.app_controller.library_view) if Settings.get().first_start: Settings.update(first_start=False).execute() path = os.path.join(Path.home(), _("Audiobooks")) Storage.create(path=path, default=True) os.makedirs(path, exist_ok=True) self.add_window(self.ui.window) mpris = MPRIS(self) mpris._on_current_changed()
def check_for_tracks(self): """ Check if there are any imported files. If there aren't display a welcome screen. """ if books().count() < 1: path = "" if Storage.select().count() > 0: path = Storage.select().where( Storage.default == True).get().path if not path: path = os.path.join(os.path.expanduser("~"), _("Audiobooks")) if not os.path.exists(path): os.mkdir(path) Storage.create(path=path, default=True) self.no_media_file_chooser.set_current_folder(path) self.main_stack.props.visible_child_name = "no_media" self.block_ui_buttons(True) self.titlebar.stop() self.category_toolbar.set_visible(False)