Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Moodkiller committed May 18, 2018
1 parent 0da1753 commit 1972a94
Show file tree
Hide file tree
Showing 35 changed files with 362,508 additions and 0 deletions.
Binary file added 7z/7-zip.chm
Binary file not shown.
Binary file added 7z/7za.exe
Binary file not shown.
29 changes: 29 additions & 0 deletions 7z/license.txt
@@ -0,0 +1,29 @@
7-Zip Command line version
~~~~~~~~~~~~~~~~~~~~~~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7-Zip Copyright (C) 1999-2010 Igor Pavlov.

7za.exe is distributed under the GNU LGPL license

Notes:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.


GNU LGPL information
--------------------

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/
41 changes: 41 additions & 0 deletions 7z/readme.txt
@@ -0,0 +1,41 @@
7-Zip Command line version 9.20
-------------------------------

7-Zip is a file archiver with high compression ratio.
7za.exe is a standalone command line version of 7-Zip.

7-Zip Copyright (C) 1999-2010 Igor Pavlov.

Features of 7za.exe:
- High compression ratio in new 7z format
- Supported formats:
- Packing / unpacking: 7z, xz, ZIP, GZIP, BZIP2 and TAR
- Unpacking only: Z, lzma
- Highest compression ratio for ZIP and GZIP formats.
- Fast compression and decompression
- Strong AES-256 encryption in 7z and ZIP formats.

7za.exe is a free software distributed under the GNU LGPL.
Read license.txt for more information.

Source code of 7za.exe and 7-Zip can be found at
http://www.7-zip.org/

7za.exe can work in Windows 95/98/ME/NT/2000/2003/2008/XP/Vista/7.

There is also port of 7za.exe for POSIX systems like Unix (Linux, Solaris, OpenBSD,
FreeBSD, Cygwin, AIX, ...), MacOS X and BeOS:

http://p7zip.sourceforge.net/


This distributive packet contains the following files:

7za.exe - 7-Zip standalone command line version.
readme.txt - This file.
license.txt - License information.
7-zip.chm - User's Manual in HTML Help format.


---
End of document
258 changes: 258 additions & 0 deletions Hexchat plugin/mpv_np.py
@@ -0,0 +1,258 @@
# requires Python 3
from abc import ABCMeta, abstractmethod
import json
import os.path
import socket
import sys
import time

import hexchat


__module_name__ = "mpv now playing (MK Mod)"
__module_version__ = "0.4.2"
__module_description__ = "Announces info of the currently loaded 'file' in mpv"

# # Configuration # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# Paths to mpv's IPC socket or named pipe.
# Set the same path in your mpv.conf `input-ipc-server` setting
# or adjust these values.
WIN_PIPE_PATH = R"\\.\pipe\mpvsocket"
UNIX_PIPE_PATH = "/tmp/mpv-socket" # variables are expanded

# Windows only:
# The command that is being executed.
# Supports mpv's property expansion:
# https://mpv.io/manual/stable/#property-expansion
CMD_FMT = R'me is playing: 07${filename} ◘ ${file-size} ◘ [${time-pos}${!duration==0: / ${duration}}] in 06${mpv-version}'

# On UNIX, the above is not supported yet
# and this Python format string is used instead.
# `{title}` will be replaced with the title.
LEGACY_CMD_FMT = "me is playing: {title} in MPV"


# # The Script # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


def _tempfile_path(*args, **kwargs):
"""Generate a sure-to-be-free tempfile path.
It's hacky but it works.
"""
import tempfile
fd, tmpfile = tempfile.mkstemp()
# close and delete; we only want the path
os.close(fd)
os.remove(tmpfile)
return tmpfile


# If asynchronous IO was to be added,
# the Win32API would need to be used on Windows.
# Details:
# - https://msdn.microsoft.com/en-us/library/windows/desktop/aa365683%28v=vs.85%29.aspx
# Examples:
# - https://msdn.microsoft.com/en-us/library/windows/desktop/aa365690%28v=vs.85%29.aspx
# - https://msdn.microsoft.com/en-us/library/windows/desktop/aa365592%28v=vs.85%29.aspx
# - https://github.com/mpv-player/mpv/blob/master/input/ipc-win.c
class MpvIpcClient(metaclass=ABCMeta):

"""Work with an open MPC instance via its JSON IPC.
In a blocking way.
Supports sending IPC commands,
input commands (input.conf style)
and arbitrary read/write_line calls.
Classmethod `for_platform`
will resolve to one of WinMpvIpcClient or UnixMpvIpcClient,
depending on the current platform.
"""

def __init__(self, path):
self.path = path
self._connect()

@classmethod
def for_platform(cls, platform=sys.platform, path=None):
if platform == 'win32':
return WinMpvIpcClient(path or WIN_PIPE_PATH)
else:
return UnixMpvIpcClient(path or UNIX_PIPE_PATH)

@abstractmethod
def _connect(self):
pass

@abstractmethod
def _write_line(self):
pass

@abstractmethod
def _read_line(self):
pass

@abstractmethod
def close(self):
pass

def command(self, command, *params):
data = json.dumps({"command": [command] + list(params)})
self._write_line(data)
while 1:
# read until a result line is found (containing "error" key)
result_line = self._read_line()
result = json.loads(result_line)
if 'error' in result:
break
if result['error'] != "success":
raise RuntimeError("mpv returned an error", result['error'])

return result['data']

def input_command(self, cmd):
"""Send an input command."""
self._write_line(cmd)

def __enter__(self):
return self

def __exit__(self, *_):
self.close()

@abstractmethod
def expand_properties(self, fmt):
"""Expand a mpv property string using its run command and platform-specific hacks.
Pending https://github.com/mpv-player/mpv/issues/3166
for easier implementation.
"""
pass


class WinMpvIpcClient(MpvIpcClient):

def _connect(self):
self._f = open(self.path, "w+t", newline='', encoding='utf-8')

def _write_line(self, line):
self._f.write(line.strip())
self._f.write("\n")
self._f.flush()

def _read_line(self):
return self._f.readline()

def close(self):
self._f.close()

def expand_properties(self, fmt, timeout=1.5):
"""Expand a mpv property string using its run command and other hacks.
Notably, spawn a Powershell process that writes a string to some file.
Because of this, there are restrictions on the property string
that will most likely *not* be met,
but are checked for anyway.
Since this is a polling-based approach (and unsafe too),
a timeout mechanic is implemented
and the wait time can be specified.
"""
if "'" in fmt or "\\n" in fmt:
raise ValueError("unsupported format string - may not contain `\\n` or `'`")

tmpfile = _tempfile_path()

# backslashes in quotes need to be escaped for mpv
self.input_command(R'''run powershell.exe -Command "'{fmt}' | Out-File '{tmpfile}'"'''
.format(fmt=fmt, tmpfile=tmpfile.replace("\\", "\\\\")))

# some tests reveal an average time requirement of 0.35s
start_time = time.time()
end_time = start_time + timeout
while time.time() < end_time:
if not os.path.exists(tmpfile):
continue
try:
with open(tmpfile, 'r', encoding='utf-16 le') as f: # Powershell writes utf-16 le
# Because we open the file faster than powershell writes to it,
# wait until there is a newline in out tmpfile (which powershell writes).
# This means we can't support newlines in the fmt string,
# but who needs those anyway?
buffer = ''
while time.time() < end_time:
result = f.read()
buffer += result
if "\n" in result:
# strip BOM and next line
buffer = buffer.lstrip("\ufeff").splitlines()[0]
return buffer
buffer += result
except OSError:
continue
else:
break
finally:
os.remove(tmpfile)


class UnixMpvIpcClient(MpvIpcClient):

buffer = b""

def _connect(self):
self._sock = socket.socket(socket.AF_UNIX)
self.expanded_path = os.path.expanduser(os.path.expandvars(self.path))
self._sock.connect(self.expanded_path)

def _write_line(self, line):
self._sock.sendall(line.strip().encode('utf-8'))
self._sock.send(b"\n")

def _read_line(self):
while 1:
if b"\n" in self.buffer:
line, _, self.buffer = self.buffer.partition(b"\n")
return line.decode('utf-8')
self.buffer += self._sock.recv(4096)

def close(self):
self._sock.close()

def expand_properties(self, fmt):
return NotImplemented


###############################################################################


def mpv_np(caller, callee, helper):
try:
with MpvIpcClient.for_platform() as mpv:
command = mpv.expand_properties(CMD_FMT)
if command is None:
print("unable to expand property string - falling back to legacy")
command = NotImplemented
if command is NotImplemented:
title = mpv.command("get_property", "media-title")
command = LEGACY_CMD_FMT.format(title=title)
hexchat.command(command)

except OSError:
# import traceback; traceback.print_exc()
print("mpv IPC not running or bad configuration (see /help mpv)")

return hexchat.EAT_ALL


if __name__ == '__main__':
help_str = (
"Usage: /mpv\n"
"Setup: set `input-ipc-server={path}` in your mpv.conf file "
"(or adjust the path in the script source)."
.format(path=WIN_PIPE_PATH if sys.platform == 'win32' else UNIX_PIPE_PATH)
)
hexchat.hook_command("mpv", mpv_np, help=help_str)
print(__module_name__, __module_version__, "loaded")
Binary file added d3dcompiler_43.dll
Binary file not shown.
Binary file added doc/manual.pdf
Binary file not shown.
Binary file added doc/mpbindings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fonts/SourceSansVariable-Italic.ttf
Binary file not shown.
Binary file added fonts/SourceSansVariable-Roman.ttf
Binary file not shown.
42 changes: 42 additions & 0 deletions installer/configure-opengl-hq.bat
@@ -0,0 +1,42 @@
@echo OFF
cd /D %~dp0\..
set mpv_path=%cd%\mpv.exe
set config_dir=%cd%\mpv
set config_file=%cd%\mpv\mpv.conf
if not exist "%mpv_path%" call :die "mpv.exe not found"
echo.
echo.
echo ////////////////////////////////////////////////////////////////////////////
echo /
echo This script will configure mpv player to use opengl-hq video output for /
echo high-quality video rendering. /
echo /
echo Opengl-hq will configure to use many useful video filters like debanding /
echo filter,dithering.. /
echo /
echo If the played video lagging a lot after using opengl-hq, delete the "mpv" /
echo folder to use default mpv's video output (opengl) which suitable for /
echo slower computer. /
echo /
echo /
echo Make sure you have write permission to create folder, /
echo %config_dir%
echo /
echo For more info about mpv's settings, read doc\manual.pdf /
echo or visit https://mpv.io/manual/master/ /
echo /
echo ////////////////////////////////////////////////////////////////////////////
echo.
echo Press "Enter" to continue..
echo.
set /P enterKey={ENTER}

mkdir "%config_dir%"
echo # High quality video rendering for fast computer. > "%config_file%"
echo profile=gpu-hq >> "%config_file%"
echo deband=no >> "%config_file%"

:die
if not [%1] == [] echo %~1
pause
exit 1
Binary file added installer/mpv-icon.ico
Binary file not shown.

0 comments on commit 1972a94

Please sign in to comment.