forked from aliva/SubtitleFixer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
nautilus-subfixer.py
34 lines (27 loc) · 985 Bytes
/
nautilus-subfixer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
import urllib
import os
from gi.repository import Nautilus
from gi.repository import GObject
from gi.repository import Gtk
class NautilusSubFixer(GObject.GObject, Nautilus.MenuProvider):
def __init__(self):
pass
def get_file_items(self, window, files):
if len(files) == 0:
return None
for f in files:
if f.get_name()[-4:] != '.srt':
return None
print files[0].get_name()
menuitem = Nautilus.MenuItem(name='NautilusSubFixer::SubFixer',
label='Fix subtitle file',
tip='Fix subtitle file',
icon='gtk-edit')
menuitem.connect('activate', self.on_menuitem_activated, files)
return menuitem,
def on_menuitem_activated(self, menuitem, files):
f_uri = ""
for f in files:
f_uri += "'%s' " % urllib.unquote(f.get_uri()[7:])
os.system('subfixer %s' % f_uri)