Skip to content

Commit

Permalink
Update to 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxe committed Sep 5, 2024
1 parent 766eda8 commit 689452f
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 48 deletions.
24 changes: 24 additions & 0 deletions addon/doc/zh_TW/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# 更新日誌

## V3.0, 2024.9.5

版本代號:人生最棒的消遣

Source:
https://youtu.be/u0OvEzIYYPM?si=injk6YAXEPrDBQKC

### 更新項目

1. 新增 Prime Video 字幕支援(感謝 Wengweng 的提案)。
測試影片:[尖叫旅社 四:變形怪獸](https://www.primevideo.com/detail/0ILGJ4D4ZYPGJCCG2VNGX3LCR3)
2. Youtube 聊天室:新增朗讀聊天橫幅,橫幅最常見的就是由頻道主設為制頂的訊息,另一個不常見的就是提問活動。
3. 由於《唱歌學日語 Marumaru 》已經關站,故從字幕閱讀器當中刪除相關的代碼。
4. 新增土耳其語支援,感謝 ghostkillerr
5. 更新芬蘭語翻譯,感謝 jkinnunen

### 修正巷木

1. 修正在不使用背景閱讀的狀況下,在某些視窗仍會繼續朗讀字幕的錯誤。
2. 修正 NVDA2019.2.1 版本無法使用字幕閱讀器的錯誤。(感謝 Ethane )
3. 修正下載更新時,進度列永遠為 0% 的錯誤。

---

## V2.97, 2024.6.16

版本代號:吉他與孤獨與藍色星球
Expand Down
14 changes: 7 additions & 7 deletions addon/globalPlugins/subtitle_reader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from . import gui
from .config import conf
from .youtube import Youtube
from .maru_maru import MaruMaru
from .disney_plus import DisneyPlus
from .netflix import Netflix
from .wkMediaCommons import WKMediaCommons
Expand All @@ -29,6 +28,7 @@
from .bilibili import Bilibili
from .iqy import Iqy
from .missevan import Missevan
from .primeVideo import PrimeVideo
from .potPlayer import PotPlayer
from .update import Update

Expand All @@ -48,15 +48,15 @@ def __new__(cls):
# 傳回附加元件的基礎類別實體,表示沒有任何功能的附加元件。
return globalPluginHandler.GlobalPlugin()

return super().__new__(cls)
return super(cls, cls).__new__(cls)

def __init__(self, *args, **kwargs):
super(GlobalPlugin, self).__init__(*args, **kwargs)
self.subtitleAlgs = {
'.+ - YouTube': Youtube(self),
'.+-MARUMARU': MaruMaru(self),
'^Disney\+ \| ': DisneyPlus(self),
'.*?Netflix': Netflix(self),
'^Prime Video: .+': PrimeVideo(self),
'.+ - Wikimedia Commons': WKMediaCommons(self),
'.+ \| KKTV': Kktv(self),
'.+LINE TV-': LineTV(self),
Expand Down Expand Up @@ -187,6 +187,10 @@ def findUrl(self):

def event_foreground(self, obj, nextHandler):
nextHandler()
if not conf['backgroundReading']:
self.stopReadSubtitle()
self.videoPlayer = None

if obj.appModule.appName not in self.supportedBrowserAppNames:
return

Expand All @@ -211,10 +215,6 @@ def executeSubtitleAlg(self):
# 嵌入的 Youtube 頁框,在開始播放約 5 秒之後,會將焦點拉到一個不明的物件上,且 NVDA 無法查看其相鄰的物件,故將他跳過。
return

if not conf['backgroundReading']:
self.stopReadSubtitle()
self.videoPlayer = None

if not conf['switch']:
return

Expand Down
15 changes: 14 additions & 1 deletion addon/globalPlugins/subtitle_reader/gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#encoding=utf-8

from __future__ import absolute_import
from __future__ import unicode_literals

import addonHandler
addonHandler.initTranslation()
Expand Down Expand Up @@ -62,6 +63,15 @@ def __init__(self):
# Translators: This menu item that can toggle automatic check for update when Subtitle Reader is start
self.checkUpdateAutomatic = self.AppendCheckItem(wx.ID_ANY, _(u'自動檢查更新(&A)'))
self.checkUpdateAutomatic.Check(True)

self.contactDeveloper = wx.Menu()
self.contactDeveloperMenuItem = self.AppendSubMenu(self.contactDeveloper, _('聯絡開發者 (&C)'))

self.useSkype = self.contactDeveloper.Append(wx.ID_ANY, 'Skype, id:p15937a')
self.useLine = self.contactDeveloper.Append(wx.ID_ANY, 'Line, id:Maxe0310 ' + _('點此複製到剪貼簿'))
self.useDiscord = self.contactDeveloper.Append(wx.ID_ANY, 'Discord, ID:maxe0310')
self.useFacebook = self.contactDeveloper.Append(wx.ID_ANY, _('Facebook 個人檔案'))
self.useX = self.contactDeveloper.Append(wx.ID_ANY, _('X, ID:Maxe0310'))


class UpdateDialog(wx.Dialog):
Expand All @@ -75,7 +85,7 @@ def __init__(self, version):
self.sizer.Add(self.changelogText, wx.SizerFlags(1).Expand())

self.subtitleLabel = Label(self, label=_(u'字幕'))
self.sizer.Add(self.subtitleLabel, wx.SizerFlags(0).CenterHorizontal())
self.sizer.Add(self.subtitleLabel, wx.SizerFlags(0).Center())

self.progress = wx.Gauge(self, style=wx.GA_VERTICAL + wx.ST_NO_AUTORESIZE)
self.sizer.Add(self.progress)
Expand All @@ -101,3 +111,6 @@ class Label(wx.StaticText):
def AcceptsFocus(self):
return True

def AcceptsFocusFromKeyboard(self):
return True

29 changes: 0 additions & 29 deletions addon/globalPlugins/subtitle_reader/maru_maru.py

This file was deleted.

7 changes: 5 additions & 2 deletions addon/globalPlugins/subtitle_reader/object_finder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#coding=utf-8

import time

from logHandler import log
Expand Down Expand Up @@ -61,7 +63,8 @@ def start(self):

def cancel(self):
self.cancelled = True
self.inspectionObjects.clear()
# python2.7 沒有 clear 方法
del self.inspectionObjects[:]

@property
def isStopped(self):
Expand All @@ -83,7 +86,7 @@ def __search(self):
if self.condition(obj):
self.onFound(obj)
if not self.continueOnFound:
self.inspectionObjects.clear()
del self.inspectionObjects[:]
return self.nextSearch()


Expand Down
9 changes: 6 additions & 3 deletions addon/globalPlugins/subtitle_reader/potPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


import speech
if hasattr(speech, 'speech'):
speech = speech.speech

import difflib
import winInputHook
import vkCodes
Expand All @@ -13,13 +16,13 @@
class PotPlayer:
def __init__(self):
self.lastSpeechText = ''
self.oldProcessText = speech.speech.processText
speech.speech.processText = self.processText
self.oldProcessText = speech.processText
speech.processText = self.processText
self.oldKeyDown = winInputHook.keyDownCallback
winInputHook.keyDownCallback = self.keyDown

def terminate(self):
speech.speech.processText = self.oldProcessText
speech.processText = self.oldProcessText
winInputHook.keyDownCallback = self.oldKeyDown

def processText(self, locale, text, symbolLevel, *args, **kwargs):
Expand Down
25 changes: 25 additions & 0 deletions addon/globalPlugins/subtitle_reader/primeVideo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#coding=utf-8

from .subtitle_alg import SubtitleAlg
from .object_finder import find
from .compatible import role

class PrimeVideo(SubtitleAlg):
def getVideoPlayer(self):
obj = self.main.focusObject
appName = obj.appModule.appName
videoPlayer = find(obj, 'parent', 'class', 'atvwebplayersdk-overlays-container fpqiyer')
if videoPlayer:
videoPlayer = obj.parent.parent.parent.parent

return videoPlayer

def getSubtitleContainer(self):
videoPlayer = self.main.videoPlayer
container = videoPlayer.next.firstChild.firstChild
return container

def getSubtitle(self):
obj = self.main.subtitleContainer
return super(PrimeVideo, self).getSubtitle(obj)

2 changes: 1 addition & 1 deletion addon/globalPlugins/subtitle_reader/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def downloadThread(self):


def updateProgress(self, blockCount, blockSize, total):
percent = 100 * blockCount * blockSize / total
percent = int(100 * blockCount * blockSize / total)
wx.CallAfter(self.dialog.progress.SetValue, percent)

def downloadError(self):
Expand Down
29 changes: 28 additions & 1 deletion addon/globalPlugins/subtitle_reader/youtube.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#coding=utf-8

from __future__ import unicode_literals

import os
import re

Expand Down Expand Up @@ -27,6 +29,7 @@ def __init__(self, *args, **kwargs):
self.chatSenderIsVerified = ''
self.chat = ''
self.voting = False
self.chatBanner = ''
self.chatContainerSearchObject = None
self.chatSearchObject = None

Expand Down Expand Up @@ -62,6 +65,7 @@ def getChatContainer(self):
self.chatContainer = None
self.chatObject = None
self.voting = None
self.chatBanner = ''
if self.chatContainerSearchObject:
self.chatContainerSearchObject.cancel()

Expand Down Expand Up @@ -90,6 +94,7 @@ def getSubtitle(self):
self.get_subtitle_object()

self.readVoting()
self.readChatBanner()
self.readChat()

def get_subtitle_object(self):
Expand Down Expand Up @@ -314,13 +319,35 @@ def onFoundChatObject(self, chat):

self.chat = text

sender = f'{self.chatSender}\r\n{self.chatSenderIsVerified}\r\n{self.chatSenderIsAdmin}\r\n'
sender = '{name}。\r\n{isVerified}。\r\n{isAdmin}。\r\n'.format(name=self.chatSender, isVerified=self.chatSenderIsVerified, isAdmin=self.chatSenderIsAdmin)
if conf['readChatSender'] or self.chatSenderIsOwner or self.chatSenderIsVerified or self.chatSenderIsAdmin:
text = sender + text

ui.message(text)


def readChatBanner(self):
if not self.chatContainer:
return

banner = self.chatContainer.parent.previous
text = ''
while banner:
obj = banner.firstChild
while obj:
if obj.name:
text += obj.name
break

obj = obj.firstChild

banner = banner.previous

if text and text not in self.chatBanner:
ui.message(text)

self.chatBanner = text

def readVoting(self):
if not self.chatRoom:
return
Expand Down
2 changes: 1 addition & 1 deletion addon/locale/fi/manifest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
summary = "Tekstityksenlukija"
description = """Lukee tekstityksen, kun kohdistus on verkkopohjaisessa videosoittimessa."""
description = """Lukee tekstitykset, kun kohdistus on verkkopohjaisessa videosoittimessa."""
2 changes: 1 addition & 1 deletion addon/locale/tr/manifest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
summary = "Altyazı Okuyucu"
description = """Odak web video oynatıcısında olduğunda NVDA'nın altyazı okumasını destekler."""
description = """Odak web video oynatıcısında olduğunda NVDA'nın altyazıyı okumasını destekler."""
2 changes: 1 addition & 1 deletion addon/manifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ summary = "字幕閱讀器"
description = """當焦點位於網頁上的影片播放器時,讓 NVDA 讀出字幕。"""
author = "福恩 <[email protected]>"
url = https://github.com/maxe-hsieh/subtitle_reader
version = 2.97
version = 3.0
docFileName = readme.html
minimumNVDAVersion = 2019.2.1
lastTestedNVDAVersion = 2024.1
Expand Down
2 changes: 1 addition & 1 deletion buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _(arg):
# Translators: Long description to be shown for this add-on on add-on information from add-ons manager
"addon_description": _("當焦點位於網頁上的影片播放器時,讓 NVDA 讀出字幕。"),
# version
"addon_version": "2.97",
"addon_version": "3.0",
# Author(s)
"addon_author": "福恩 <[email protected]>",
# URL for the add-on documentation support
Expand Down

0 comments on commit 689452f

Please sign in to comment.