From fd83edb4591ac7fb5195f074542df5aca8c7a247 Mon Sep 17 00:00:00 2001 From: MrGeorgen Date: Sun, 13 Dec 2020 23:41:36 +0100 Subject: [PATCH] removed open with --- mid3cp | 8 ++ mid3iconv | 8 ++ mid3v2 | 8 ++ moggsplit | 8 ++ mutagen-inspect | 8 ++ mutagen-pony | 8 ++ open_with_linux.py | 186 --------------------------------------------- unidecode | 8 ++ 8 files changed, 56 insertions(+), 186 deletions(-) create mode 100755 mid3cp create mode 100755 mid3iconv create mode 100755 mid3v2 create mode 100755 moggsplit create mode 100755 mutagen-inspect create mode 100755 mutagen-pony delete mode 100755 open_with_linux.py create mode 100755 unidecode diff --git a/mid3cp b/mid3cp new file mode 100755 index 0000000..daa930b --- /dev/null +++ b/mid3cp @@ -0,0 +1,8 @@ +#!/usr/bin/python3.8 +# -*- coding: utf-8 -*- +import re +import sys +from mutagen._tools.mid3cp import entry_point +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(entry_point()) diff --git a/mid3iconv b/mid3iconv new file mode 100755 index 0000000..88e0588 --- /dev/null +++ b/mid3iconv @@ -0,0 +1,8 @@ +#!/usr/bin/python3.8 +# -*- coding: utf-8 -*- +import re +import sys +from mutagen._tools.mid3iconv import entry_point +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(entry_point()) diff --git a/mid3v2 b/mid3v2 new file mode 100755 index 0000000..0343f81 --- /dev/null +++ b/mid3v2 @@ -0,0 +1,8 @@ +#!/usr/bin/python3.8 +# -*- coding: utf-8 -*- +import re +import sys +from mutagen._tools.mid3v2 import entry_point +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(entry_point()) diff --git a/moggsplit b/moggsplit new file mode 100755 index 0000000..cfa0d92 --- /dev/null +++ b/moggsplit @@ -0,0 +1,8 @@ +#!/usr/bin/python3.8 +# -*- coding: utf-8 -*- +import re +import sys +from mutagen._tools.moggsplit import entry_point +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(entry_point()) diff --git a/mutagen-inspect b/mutagen-inspect new file mode 100755 index 0000000..6b4a888 --- /dev/null +++ b/mutagen-inspect @@ -0,0 +1,8 @@ +#!/usr/bin/python3.8 +# -*- coding: utf-8 -*- +import re +import sys +from mutagen._tools.mutagen_inspect import entry_point +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(entry_point()) diff --git a/mutagen-pony b/mutagen-pony new file mode 100755 index 0000000..9b549d7 --- /dev/null +++ b/mutagen-pony @@ -0,0 +1,8 @@ +#!/usr/bin/python3.8 +# -*- coding: utf-8 -*- +import re +import sys +from mutagen._tools.mutagen_pony import entry_point +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(entry_point()) diff --git a/open_with_linux.py b/open_with_linux.py deleted file mode 100755 index 6a4f979..0000000 --- a/open_with_linux.py +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function - -import os -import sys -import json -import struct -import subprocess - -VERSION = '7.2.2' - -try: - sys.stdin.buffer - - # Python 3.x version - # Read a message from stdin and decode it. - def getMessage(): - rawLength = sys.stdin.buffer.read(4) - if len(rawLength) == 0: - sys.exit(0) - messageLength = struct.unpack('@I', rawLength)[0] - message = sys.stdin.buffer.read(messageLength).decode('utf-8') - return json.loads(message) - - # Send an encoded message to stdout - def sendMessage(messageContent): - encodedContent = json.dumps(messageContent).encode('utf-8') - encodedLength = struct.pack('@I', len(encodedContent)) - - sys.stdout.buffer.write(encodedLength) - sys.stdout.buffer.write(encodedContent) - sys.stdout.buffer.flush() - -except AttributeError: - # Python 2.x version (if sys.stdin.buffer is not defined) - # Read a message from stdin and decode it. - def getMessage(): - rawLength = sys.stdin.read(4) - if len(rawLength) == 0: - sys.exit(0) - messageLength = struct.unpack('@I', rawLength)[0] - message = sys.stdin.read(messageLength) - return json.loads(message) - - # Send an encoded message to stdout - def sendMessage(messageContent): - encodedContent = json.dumps(messageContent) - encodedLength = struct.pack('@I', len(encodedContent)) - - sys.stdout.write(encodedLength) - sys.stdout.write(encodedContent) - sys.stdout.flush() - - -def install(): - home_path = os.getenv('HOME') - - manifest = { - 'name': 'open_with', - 'description': 'Open With native host', - 'path': os.path.realpath(__file__), - 'type': 'stdio', - } - locations = { - 'chrome': os.path.join(home_path, '.config', 'google-chrome', 'NativeMessagingHosts'), - 'chrome-beta': os.path.join(home_path, '.config', 'google-chrome-beta', 'NativeMessagingHosts'), - 'chrome-unstable': os.path.join(home_path, '.config', 'google-chrome-unstable', 'NativeMessagingHosts'), - 'chromium': os.path.join(home_path, '.config', 'chromium', 'NativeMessagingHosts'), - 'firefox': os.path.join(home_path, '.mozilla', 'native-messaging-hosts'), - } - filename = 'open_with.json' - - for browser, location in locations.items(): - if os.path.exists(os.path.dirname(location)): - if not os.path.exists(location): - os.mkdir(location) - - browser_manifest = manifest.copy() - if browser == 'firefox': - browser_manifest['allowed_extensions'] = ['openwith@darktrojan.net'] - else: - browser_manifest['allowed_origins'] = [ - 'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/', # Chrome - 'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/', # Opera - ] - - with open(os.path.join(location, filename), 'w') as file: - file.write( - json.dumps(browser_manifest, indent=2, separators=(',', ': '), sort_keys=True).replace(' ', '\t') + '\n' - ) - - -def _read_desktop_file(path): - with open(path, 'r') as desktop_file: - current_section = None - name = None - command = None - for line in desktop_file: - if line[0] == '[': - current_section = line[1:-2] - if current_section != 'Desktop Entry': - continue - - if line.startswith('Name='): - name = line[5:].strip() - elif line.startswith('Exec='): - command = line[5:].strip() - - return { - 'name': name, - 'command': command - } - - -def find_browsers(): - apps = [ - 'Chrome', - 'Chromium', - 'chromium-browser', - 'firefox', - 'Firefox', - 'Google Chrome', - 'google-chrome', - 'opera', - 'Opera', - 'SeaMonkey', - 'seamonkey', - ] - paths = [ - os.path.join(os.getenv('HOME'), '.local/share/applications'), - '/usr/local/share/applications', - '/usr/share/applications' - ] - suffix = '.desktop' - - results = [] - for p in paths: - for a in apps: - fp = os.path.join(p, a) + suffix - if os.path.exists(fp): - results.append(_read_desktop_file(fp)) - return results - - -def listen(): - receivedMessage = getMessage() - if receivedMessage == 'ping': - sendMessage({ - 'version': VERSION, - 'file': os.path.realpath(__file__) - }) - elif receivedMessage == 'find': - sendMessage(find_browsers()) - else: - for k, v in os.environ.items(): - if k.startswith('MOZ_'): - try: - os.unsetenv(k) - except: - os.environ[k] = '' - - devnull = open(os.devnull, 'w') - subprocess.Popen(receivedMessage, stdout=devnull, stderr=devnull) - sendMessage(None) - - -if __name__ == '__main__': - if len(sys.argv) == 2: - if sys.argv[1] == 'install': - install() - sys.exit(0) - elif sys.argv[1] == 'find_browsers': - print(find_browsers()) - sys.exit(0) - - allowed_extensions = [ - 'openwith@darktrojan.net', - 'chrome-extension://cogjlncmljjnjpbgppagklanlcbchlno/', - 'chrome-extension://fbmcaggceafhobjkhnaakhgfmdaadhhg/', - ] - for ae in allowed_extensions: - if ae in sys.argv: - listen() - sys.exit(0) - - print('Open With native helper, version %s.' % VERSION) diff --git a/unidecode b/unidecode new file mode 100755 index 0000000..d0e4285 --- /dev/null +++ b/unidecode @@ -0,0 +1,8 @@ +#!/usr/bin/python3.8 +# -*- coding: utf-8 -*- +import re +import sys +from unidecode.util import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main())