Created
September 29, 2019 20:13
-
-
Save neta1/44902ea8b01764116bb0b42ba4750dea to your computer and use it in GitHub Desktop.
avsファイルのTrim指定からブックマークをインポートするAvsPmod用マクロ (主にAmatsukazeが一時出力するtrim0.avs向け)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
filename = avsp.GetFilename(_('Select a file'), filefilter= | |
_('.trim.avs files') + ' (*.avs)|*.avs|'+ | |
_('All files') + ' (*.*)|*.*') | |
if not filename: | |
return | |
lines = avsp.GetWindow().GetTextFromFile(filename)[0] | |
bookmarkDict = {} | |
# parsing .trim.avs files | |
if not bookmarkDict: | |
timeList = re.findall(r'Trim\(\s*(\d+)\s*,\s*(\d+)\s*\)', lines) | |
if timeList: | |
for inFrame, outFrame in timeList: | |
bookmarkDict[int(inFrame)] = 'IN' | |
bookmarkDict[int(outFrame)] = 'OUT' | |
if bookmarkDict: | |
bookmarkList = bookmarkDict.items() | |
# Don't delete current bookmarks, update its title if supplied | |
oldBookmarks = avsp.GetBookmarkList() | |
for bookmark, title in bookmarkDict.items(): | |
if bookmark in oldBookmarks: | |
if title: | |
bookmarkList.append((bookmark, title)) | |
else: | |
bookmarkList.remove((bookmark, title)) | |
avsp.SetBookmark(bookmarkList) | |
else: | |
avsp.MsgBox(_('Bookmark file unrecognized!'), _('Error')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment