0
1

More than 3 years have passed since last update.

Netflixの字幕をVBAで抽出する

Posted at

英語学習のためお気に入りの映画の字幕をVBAで抽出してみる

私は英語とVBAの学習を同時に行っている。
Google Chromeの拡張機能で字幕をダウンロードしたところ必要ないテキストがついていたので
VBAで必要なテキストを抽出することにした。
前提条件
・Netflix - subtitle downloaderでダウンロードした.vttファイルがある
・エクセルがインストールされている

ファイル読み込み

ファイルを読み込んでみる。

・モジュール
Option Explicit

Public Enum SETCOL
C_PATH = 2
End Enum

Public Enum SETROW
R_PATH = 2
End Enum

Private Const START_TAG_ = ""
Private Const END_TAG_ = ""

'''


'''
''' NETFLLIXの英語字幕を抽出
'''
'''

Sub Extraction()
'カレントディレクトリを変更
ChDrive Left(ThisWorkbook.Path, 1)
ChDir ThisWorkbook.Path
Dim buf As String
Dim str As String
Dim myTitle As String
Dim c As common: Set c = New common
Open c.GetFilePath For Input As #1
Do Until EOF(1)
Line Input #1, buf
debug.print byf
Loop
Close #1
End Sub

・クラス
'''


'''
''' テキストファイル出力
'''
'''

Function GetFilePath() As String
Dim prompt As String: prompt = "ファイルを選択して下さい"
Dim fPath As Variant
fPath = Application.GetOpenFilename("", , prompt)
If fPath = False Then End
GetFilePath = fPath
End Function

これで、ダイアログから選択した.vttファイルをプログラム内に読み込んだ。
しかしDebug.printで出力するとファイルの内容をすべて一回の読み込みで取ってきている。
一行ずつ抽出して加工したいのでこれではいけない。
次回は原因を調査し抽出したテキストを出力までたどり着きたい。

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1