mpv2oboeru

mpv helpers to create flashcards from movies and TV shows
git clone anongit@rnpnr.xyz:mpv2oboeru.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 38f62c001da816cd1b8a68d18cd8fa2ddb31a6cd
Parent: 7b7412c4f75944b1b95e621241f474eeafd3ba07
Author: Ren Tatsumoto
Date:   Mon, 14 Dec 2020 18:27:01 +0300

remove unused code

Diffstat:
MREADME.md | 10----------
Msubs2srs.lua | 39---------------------------------------
2 files changed, 0 insertions(+), 49 deletions(-)

diff --git a/README.md b/README.md @@ -159,9 +159,6 @@ Example configuration file: # General settings # #################### -# Your Anki username. It is displayed on the title bar of the Anki window. -anki_user=User 1 - # The deck will be created if it doesn't exist. Subdecks are supported. deck_name=Bank::subs2srs @@ -249,13 +246,6 @@ vocab_field=VocabKanji vocab_audio_field=VocabAudio ``` -If you run Anki in portable mode, the path to your `collection.media` folder -may differ from the default. In this case, if you run into troubles making Anki cards with the add-on, -specify full path to the collection in the `config file` as well: -``` -collection_path=C:\AnkiDataFolder\collection.media -``` - Sentence field should be first in the note type settings. Otherwise Anki won't allow mpvacious to add new notes. Alternatively, refer to [Modifying cards added with Yomichan](#modifying-cards-added-with-yomichan) diff --git a/subs2srs.lua b/subs2srs.lua @@ -36,8 +36,6 @@ For complete usage guide, see <https://github.com/Ajatt-Tools/mpvacious/blob/mas ]] local config = { - collection_path = "", -- full path to the collection. most users should leave it empty. - anki_user = "User 1", -- your anki username. it is displayed on the title bar of the Anki window. autoclip = false, -- copy subs to the clipboard or not nuke_spaces = true, -- remove all spaces or not clipboard_trim_enabled = true, -- remove unnecessary characters from strings before copying to the clipboard @@ -113,17 +111,6 @@ local function is_running_macOS() return mp.get_property('options/cocoa-force-dedicated-gpu') ~= nil end -local function is_dir(path) - if is_empty(path) then - return false - end - local file_info = utils.file_info(path) - if file_info == nil then - return false - end - return file_info.is_dir == true -end - local function contains_non_latin_letters(str) return str:match("[^%c%p%s%w]") end @@ -424,13 +411,6 @@ do return ret.status == 0 and ret.stdout:match('--oac=libopus') end - local function set_collection_path() - if not is_dir(config.collection_path) then - -- collection path wasn't specified. construct it using config.anki_user - config.collection_path = platform.construct_collection_path() - end - end - local function set_audio_format() if config.audio_format == 'opus' and is_opus_supported() then config.audio_codec = 'libopus' @@ -469,7 +449,6 @@ do end validate_config = function() - set_collection_path() set_audio_format() set_video_format() check_snapshot_settings() @@ -492,10 +471,6 @@ local function init_platform_windows() mp.commandv("run", "cmd.exe", "/d", "/c", string.format("@echo off & chcp 65001 & echo %s|clip", text)) end - self.construct_collection_path = function() - return string.format([[%s\Anki2\%s\collection.media\]], os.getenv('APPDATA'), config.anki_user) - end - self.curl_request = function(request_json, completion_fn) local handle = io.open(curl_tmpfile_path, "w") handle:write(request_json) @@ -522,16 +497,6 @@ end local function init_platform_nix() local self = {} local clip = is_running_macOS() and 'LANG=en_US.UTF-8 pbcopy' or 'xclip -i -selection clipboard' - local collection_path_linux = string.format( - '%s/.local/share/Anki2/%s/collection.media/', - os.getenv('HOME'), - config.anki_user - ) - local collection_path_mac = string.format( - '%s/Library/Application Support/Anki2/%s/collection.media', - os.getenv('HOME'), - config.anki_user - ) self.tmp_dir = function() return '/tmp' @@ -543,10 +508,6 @@ local function init_platform_nix() handle:close() end - self.construct_collection_path = function() - return is_dir(collection_path_mac) and collection_path_mac or collection_path_linux - end - self.curl_request = function(request_json, completion_fn) local args = { 'curl', '-s', 'localhost:8765', '-X', 'POST', '-d', request_json } return subprocess(args, completion_fn)