Avdump2 on Linux: Difference between revisions

Jump to navigation Jump to search
{{Avdump-current-version}}
(Added error explanation for incorrect file name encoding)
({{Avdump-current-version}})
 
(9 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{TOCright}}
{{eyecatch|WARNING|This article was written for [[Avdump2]]. The current latest version is {{Avdump-current-version}}, and the steps in this article have not yet been explicitly verified against {{Avdump-current-version}}.}}
[[Avdump2]] was developed on Windows, for Windows. Thanks to Mono it’s possible to run Avdump2 on Linux and all efforts are made to support all features on Linux as well, but handling every peculiarity of every Mono version on every Linux installation is beyond the scope of Avdump2 at this time. Therefore, some things just don’t work on Linux, or at least not right away, without some workarounds.
[[Avdump2]] was developed on Windows, for Windows. Thanks to Mono it’s possible to run Avdump2 on Linux and all efforts are made to support all features on Linux as well, but handling every peculiarity of every Mono version on every Linux installation is beyond the scope of Avdump2 at this time. Therefore, some things just don’t work on Linux, or at least not right away, without some workarounds.


Line 7: Line 9:


=== Mono ===
=== Mono ===
Avdump2 has successfully been tested with Mono 2.4 on Ubuntu and with Mono 2.8 on Gentoo.
Avdump2 has successfully been tested with Mono 2.4 on Ubuntu, with Mono 2.8 on Gentoo, and Mono 5.20 on openSUSE Tumbleweed.


'''<tt>Avdump2CL.exe</tt> looks like a Windows .exe, how do I start it?'''
'''<tt>Avdump2CL.exe</tt> looks like a Windows .exe, how do I start it?'''
Line 16: Line 18:


On 32 bit systems Avdump2 sometimes dies with that error when processing many files at once due to heap memory fragmentation. If you use a donelog you can just restart Avdump2 and it’ll continue from where it crashed.
On 32 bit systems Avdump2 sometimes dies with that error when processing many files at once due to heap memory fragmentation. If you use a donelog you can just restart Avdump2 and it’ll continue from where it crashed.
'''Mono complains about not being able to load type 'AVDump2CL.CL''''
The actual error message probably looks similar to this:
<tt>Unhandled Exception: System.TypeLoadException: Could not load type 'AVDump2CL.CL' from assembly 'AVDump2CL, Version=0.1.6438.0, Culture=neutral, PublicKeyToken=null'.</tt>
If you get this error then you probably don’t have all necessary mono packages installed. On a Debian-based system make sure that you have the packages <tt>libmono-corlib2.0-cil</tt> and <tt>libmono-system2.0-cil</tt> installed.


=== libMediaInfo ===
=== libMediaInfo ===
Line 33: Line 43:


If you modified ''any'' of the required files Avdump2 came with, you will either get a version error or several timeouts and no meaningful error message. So no, you can’t edit the config file either.
If you modified ''any'' of the required files Avdump2 came with, you will either get a version error or several timeouts and no meaningful error message. So no, you can’t edit the config file either.


'''Failed to create MediaInfoProvider'''
'''Failed to create MediaInfoProvider'''
Line 41: Line 50:
<tt>Invalid value returned by mil. This error may indicate that your LANG or LC_ALL environment variables are not set to use UTF-8 encoding.</tt>
<tt>Invalid value returned by mil. This error may indicate that your LANG or LC_ALL environment variables are not set to use UTF-8 encoding.</tt>


This error appears if you try to process a file with special characters in its name and your locale settings don’t match the file system encoding. Nowadays almost all file names are encoded with UTF-8 on Linux, so your locale should use that as well. If you work remotely on a server that sets LANG to “C” by default, it won’t work. Try setting LC_ALL=en_US.UTF-8, because that locale is installed almost everywhere by default. LC_ALL takes precedence over LANG.
This error appears if you try to process a file with special characters in its name and your locale settings don’t match the file system encoding. Nowadays almost all file names are encoded with UTF-8 on Linux, so your locale should use that as well. If you work remotely on a server that sets LANG to “C” by default, it won’t work. Try setting LC_ALL=en_US.UTF-8, because that locale is installed almost everywhere by default. LC_ALL takes precedence over LANG. Have a look at the example script below to see how to make the setting automatically.


If you have a file with bogus characters in its name, even changing the locale won’t help. You have to rename the file to something sensible.
If you have a file with bogus characters in its name, even changing the locale won’t help. You have to rename the file to something sensible.
=== dotnet ===
Avdump2 also works on Linux via '''dotnet'''; it is about 30% faster than running it via '''mono''', but appears to work with ASCII filenames only.
Create a <tt>AVDump2CL.runtimeconfig.json</tt> in the folder that contains '''AVDump2CL.exe''' with the following content:
<pre>{
    "runtimeOptions": {
        "configProperties": {
            "System.GC.Server": true,
            "System.GC.Concurrent": true,
            "System.Threading.ThreadPool.MinThreads": 6,
            "System.Threading.ThreadPool.MaxThreads": 24
        },
        "tfm": "netcoreapp3.1",
        "framework": {
            "name": "Microsoft.NETCore.App",
            "version": "3.1.1"                                                                                                                                                                                                                                                                       
        },
        "applyPatches": true,
        "rollForwardOnNoCandidateFx": 1
    }
}</pre>
Move the Linux lib to the DLL filename so '''dotnet''' finds it
<pre>mv MediaInfo_x64.dll MediaInfo_x64.dll.windows
cp -a libMediaInfo_x64.so MediaInfo_x64.dll
</pre>


== Workarounds ==
== Workarounds ==
Line 57: Line 92:
To make using Avdump2 more comfortable, you can use or modify this wrapper script to handle the workarounds. Save it as <tt>/usr/local/bin/avdump2cl</tt>, for example. This example assumes that you extracted Avdump2 to <tt>/usr/local/lib/avdump2</tt>.
To make using Avdump2 more comfortable, you can use or modify this wrapper script to handle the workarounds. Save it as <tt>/usr/local/bin/avdump2cl</tt>, for example. This example assumes that you extracted Avdump2 to <tt>/usr/local/lib/avdump2</tt>.


A simple wrapper to set the <tt>LD_LIBRARY_PATH</tt> and to fix the cursor after using ^C:
A simple wrapper to set the <tt>LD_LIBRARY_PATH</tt>, check the locale for UTF-8 and to fix the cursor after using ^C:
<pre>
<pre>
#!/bin/bash
#!/bin/bash
Line 64: Line 99:


export LD_LIBRARY_PATH=${AVDUMP2_HOME}
export LD_LIBRARY_PATH=${AVDUMP2_HOME}
# fix bug with ncurses 6.1+
# mono/issues/6752
export TERM=xterm


# If libMediaInfo still can't be found, uncomment this.
# If libMediaInfo still can't be found, uncomment this.
#export MONO_PATH=${AVDUMP2_HOME}
#export MONO_PATH=${AVDUMP2_HOME}
# Make sure that the locale uses UTF-8 encoding.
# Remove this if your file system actually uses something else.
shopt -s extglob
if [ -z "$LC_ALL" ]; then
  LC_ALL="$LANG"
fi
if [ "$LC_ALL" == "${LC_ALL%[Uu][Tt][Ff]?(-)8}" ]; then
  LC_ALL=en_US.UTF-8
fi
export LC_ALL
export LANG="$LC_ALL"


if ! mono ${AVDUMP2_HOME}/AVDump2CL.exe "$@" ; then
if ! mono ${AVDUMP2_HOME}/AVDump2CL.exe "$@" ; then
Line 72: Line 123:
   setterm -cursor on
   setterm -cursor on
fi
fi
</pre>
== Making Your Life Easier ==
When you made sure everything works fine, if you just want to easily hash files and generate ED2K links for adding new files, you could use this roughly-made Python 2 script. (best paired with Nautilus or Nemo actions)
Please note that this script relies on Zenity extension to display the dialog containing the generated ED2K links. If you get an error running this script, please make sure you have it installed.
<pre>
#!/usr/bin/python
import sys, os, subprocess
### EDIT THE FOLLOWING ACCORDING TO YOUR INFO
AVDUMP2CL_PATH = "/path/to/your/AVDump2CL.exe"
USERNAME = " "
API_KEY = " "
###
command = "mono %s --Auth=%s:%s --PrintEd2kLink -q" % (AVDUMP2CL_PATH, USERNAME, API_KEY)
for arg in sys.argv[1:]:
    command += " \"%s\"" % arg
output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = output.stdout.readlines()
ed2k = ""
for line in output:
    if line[0:4] == "ed2k":
        ed2k += line
os.system("zenity --info --text '%s'" % ed2k.rstrip())
</pre>
</pre>


Line 86: Line 168:


Avdump2 exits with a return code of 0 on some errors, so don’t rely on the return code. It exits with a non-zero code on most serious errors, though.
Avdump2 exits with a return code of 0 on some errors, so don’t rely on the return code. It exits with a non-zero code on most serious errors, though.
[[Category:Features]]
[[Category:AniDB Clients]]
[[Category:Avdump]]
[[Category:Development]]
staff
1,114

edits

Navigation menu

MediaWiki spam blocked by CleanTalk.
MediaWiki spam blocked by CleanTalk.