-
Notifications
You must be signed in to change notification settings - Fork 8
/
nautilus-subtitlefixer.py
34 lines (27 loc) · 1.02 KB
/
nautilus-subtitlefixer.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 NautilusSubtitleFixer(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='NautilusSubtitleFixer::SubtitleFixer',
label='اصلاح زیرنویس پارسی',
tip='اصلاح زیرنویس پارسی',
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('subtitlefixer %s' % f_uri)