Advertisement
Guest User

Insert Trims from bookmarks MOD (single-line).py

a guest
Feb 21st, 2014
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.60 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. """
  4. Insert a full line of Trims, based on the video frame bookmarks, at the
  5. current cursor position of the Avisynth script in the current tab.
  6.  
  7.  
  8. Date: 2013-07-22 mod by AmjadSONY
  9. Latest version:     https://github.com/vdcrim/avsp-macros
  10. Doom9 Forum thread: http://forum.doom9.org/showthread.php?t=163653
  11.  
  12. Changelog:
  13. - check if there's bookmarks
  14. - make a full trim line based on bookmarks
  15. - fix Python 2.6 compatibility
  16.  
  17.  
  18. Copyright (C) 2011  Diego Fernández Gosende <dfgosende@gmail.com>
  19.  
  20. This program is free software: you can redistribute it and/or modify
  21. it under the terms of the GNU General Public License as published by
  22. the Free Software Foundation, either version 2 of the License, or
  23. (at your option) any later version.
  24.  
  25. This program is distributed in the hope that it will be useful,
  26. but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  28. GNU General Public License for more details.
  29.  
  30. You should have received a copy of the GNU General Public License along
  31. with this program.  If not, see <http://www.gnu.org/licenses/gpl-2.0.html>.
  32.  
  33. """
  34.  
  35. # run in thread
  36. bm_list = avsp.GetBookmarkList()
  37. if not bm_list:
  38.     avsp.MsgBox(_('There is not bookmarks'), _('Error'))
  39.     return
  40. bm_list.sort()
  41. trims = ''
  42. for i, bm in enumerate(bm_list):
  43.     if i<1:
  44.         trims += 'Trim(0, {1})++'.format(bm_list[i - 1], bm-1)
  45.     else:
  46.         trims += 'Trim({0}, {1})++'.format(bm_list[i - 1], bm-1)
  47. avsp.InsertText(trims[:-2] + '++Trim({0}, {1})'.format(bm, str(avsp.GetVideoFramecount() - 1)), pos=None)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement