Remove Thumbnail from MP3 FILE - from yt-audio - file

When using yt-audio, how can you remove the thumbnail image (artwork / screenshot) that comes with the downloaded mp3 file?
Best would be to have a way of doing it by adding an additional argument to the command, but looping through the downloaded files works too if someone knows how to do that.
Just in case, this is the description of the yt-audio usage:
usage: yt-audio [OPTIONS] REQUIRED_ARGS
A simple, configurable youtube-dl wrapper for downloading and managing youtube audio.
Required Arguments (Any/all):
URL[::DIR] Video/Playlist URL with (optional) save directory [URL::dir]
-e, --example1 Example playlist [Custom]
--all All [Custom] Arguments
Optional Arguments:
-h, --help show this help message and exit
-v, --version show version and exit
--use-archive use archive file to track downloaded titles
--use-metadata use metadata to track downloaded titles
--output-format [OUTPUT_FORMAT]
File output format
--ytdl-args [YTDL_ADDITIONAL_ARGS]
youtube-dl additional arguments
Thank you all!!

So in the end, I found the answer to this one myself (quite ashamed of the time it took me though.)
To remove the thumbnail, don't download it.
That sums it up basically.
To not download the thumbnail, I simply needed to edit the common.py file once yt-audio was installed.
The file is in the installation, under: yt_audio/common.py
Editing the common.py file.
In common.py find the Common class, and edit DEFAULT_ARGUMENT_VALUES.
Or simply replace the value assigned to it, with this thumbnail-less version (below).
DEFAULT_ARGUMENT_VALUES = {
'download_command': 'youtube-dl -x -q --print-json --audio-format mp3 --audio-quality 0 '
'--add-metadata -o "$OUTPUT$" $URL$',
'playlist_info_command': 'youtube-dl --flat-playlist -J $PLAYLIST_URL$',
'output_format': '%%(title)s.%%(ext)s',
'ffprobe_command': 'ffprobe -v quiet -print_format json -show_format -hide_banner "$PATH$"',
'output_directory': str(PurePath(Path.home(), "Music"))
}
That's it.

Related

Any way to download latest GitHub release w/ a batch script?

So, I'm trying to download the latest release from GitHub using a Windows batch script. I can get a long list of URLs by running curl -s https://api.github.com/repos/ActualMandM/cemu_graphic_packs/releases/latest, but I can't figure out how to pass the "browser_download_url": "https://github.com/ActualMandM/cemu_graphic_packs/releases/download/Github828/graphicPacks828.zip" it outputs to curl. I've looked online, but everything I found was for PowerShell and most of them used wget.
If you really want to use batch for this, you'll have to search the output JSON for the value you're looking for and then process that string. If the JSON had appeared all on one line, you'd need to take a different approach, but you got lucky.
for /f "tokens=1,* delims=:" %%A in ('curl -ks https://api.github.com/repos/ActualMandM/cemu_graphic_packs/releases/latest ^| find "browser_download_url"') do (
curl -kOL %%B
)
I've added the -k flag because my computer requires it for some reason (so other peoples' might as well).
-O will set the name of the output file to the remote output file name
-L follows a redirect, which is required for downloading from Github.
The Github API url you're accessing returns JSON, so you're going to need a JSON parser.
I can highly recommend xidel. xidel can open and download urls, so you won't need curl or a batch-script.
To query the "browser_download_url"-attribute:
xidel.exe -s "https://api.github.com/repos/ActualMandM/cemu_graphic_packs/releases/latest" -e "$json//browser_download_url"
https://github.com/ActualMandM/cemu_graphic_packs/releases/download/Github874/graphicPacks874.zip
(or -e "$json/(assets)()/browser_download_url" in full)
To download 'graphicPacks874.zip' in the current dir:
xidel.exe ^
-s "https://api.github.com/repos/ActualMandM/cemu_graphic_packs/releases/latest" ^
-f "$json//browser_download_url" ^
--download "{substring-after($headers[starts-with(.,'Content-Disposition')],'filename=')}"
With r8389 or newer (because of this commit) you can just use --download ..

How to view apps packageName with ADB commands? [duplicate]

I need to get the package name of an Android APK. I have tried to unzip the APK and read the contents of the AndroidManifest.xml file but it seems that it's not a text file.
How can I extract the APK's package name?
aapt dump badging <path-to-apk> | grep package:\ name
Install the apk on your Android device. Then
you can launch adb shell and execute pm list packages -f, which shows the package name for each installed apk.
This is taken from
Find package name for Android apps to use Intent to launch Market app from web.
Based on #hackbod answer ... but related to windows.
aapt command is located on Android\SDK\build-tools\version.
If you need more info about what is appt command (Android Asset Packaging Tool) read this https://stackoverflow.com/a/28234956/812915
The dump sub-command of aapt is used to display the values of individual elements or parts of a package:
aapt dump badging <path-to-apk>
If you want see only the line with package: name info, use findstr
aapt dump badging <path-to-apk> | findstr -n "package: name" | findstr "1:"
Hope it help other windows user!
If you are looking at google play and want to know its package name then you can look at url or address bar. You will get package name. Here com.landshark.yaum is the package name
https://play.google.com/store/apps/details?id=com.landshark.yaum&feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5sYW5kc2hhcmsueWF1bSJd
The following bash script will display the package name and the main activity name:
apk_package.sh
package=$(aapt dump badging "$*" | awk '/package/{gsub("name=|'"'"'",""); print $2}')
activity=$(aapt dump badging "$*" | awk '/activity/{gsub("name=|'"'"'",""); print $2}')
echo
echo " file : $1"
echo "package : $package"
echo "activity: $activity"
run it like so:
apk_package.sh /path/to/my.apk
If you open the AndroidManifest.xml using MS Notepad, search for phrase package and you'll find following:
package manifest $xxx.xxxxxxx.xxxxxxx |
where xxx.xxxxxxx.xxxxxxx is your package name, just written with a space after each character.
It's useful way when you don't have any specific tools installed.
Since its mentioned in Android documentation that AAPT has been deprecated, getting the package name using AAPT2 command in Linux is as follows:
./aapt2 dump packagename <path_to_apk>
Since I am using an older version of Gradle build, I had to download a newer version of AAPT2 as mentioned here :
Download AAPT2 from Google Maven
Using the build-tools in my sdk - 25.0.3, 26.0.1 and 27.0.3, executing the aapt2 command shows an error: Unable to open 'packagename': No such file or directory. That's why I went for the newer versions of AAPT2.
I used 3.3.0-5013011 for linux.
A Programmatic Answer
If you need to do this programmatically, it's a little more involved than just getting the answer into your brain. I have a script that I use to sign all of our apps, but each use a different key. Here are 2 ways to get just the Package Name as output so you can put it in a variable or do whatever you need with it.
Example output: com.example.appname (and nothing more)
Requirements
aapt - Android Asset Packaging Tool, part of the SDK Tools download
Solution 1
Using awk specify ' as the Field Separator, search for a line with package: name=, and print only the 2nd "field" in the line:
aapt dump badging /path/to/file.apk | awk -v FS="'" '/package: name=/{print $2}'
A weakness of this method is that it relies on aapt to output the package information fields in the same order:
package: name='com.example.appname' versionCode='3461' versionName='2.2.4' platformBuildVersionName='4.2.2-1425461'
We have no commitments from the developers to maintain this format.
Solution 2
Using awk specify " as the Field Separator, search for a line with package=, and print only the 2nd "field" in the line:
aapt list -a /path/to/file.apk | awk -v FS='"' '/package=/{print $2}'
A weakness of this method is that it relies on aapt to output package= only in the Android Manifest: section of the output. We have no commitments from the developers to maintain this format.
Solution 3
Expand the apk file with apktool d and read the AndroidManifest.xml.
This would be the best method, but the AndroidManifest.xml is a binary file and all the SO answers I see for converting it to text do not work. (Using apktool d instead of a simple unzip is supposed to do this for you, but it does not.) Please comment if you have an solution to this issue
A simple solution would be Open Android Studio -> Build -> Analyze Apk... browse and select the APK now you can find the package name and pretty much you can read.
You can use Analyze APK... from the Build menu in Android Studio, it will display the package name at the top of new window.
If you don't have the Android SDK installed, like in some test scenarios, you can get the package name using the following bash method:
getAppIdFromApk() {
local apk_path="$1"
# regular expression (required)
local re="^\"L.*/MainActivity;"
# sed substitute expression
local se="s:^\"L\(.*\)/MainActivity;:\1:p"
# tr expression
local te=' / .';
local app_id="$(unzip -p $apk_path classes.dex | strings | grep -Eo $re | sed -n -e $se | tr $te)"
echo "$app_id"
}
Tested on a mac. 'strings' and 'unzip' are standard on most linux's, so should work on linux too.
A very simple method is to use apkanalyzer.
apkanalyzer manifest application-id "${_path_to_apk}"
On Mac:
Way 1:
zgong$ /Users/zgong/Library/Android/sdk/build-tools/29.0.3/aapt dump badging ~/Downloads/NonSIMCC-151-app-release-signed.apk
package: name='com.A.B' versionCode='2020111801' versionName='1.0.40' compileSdkVersion='29' compileSdkVersionCodename='10'
sdkVersion:'24'
targetSdkVersion:'29'
......
Way 2:
/Users/zgong/Library/Android/sdk/build-tools/29.0.3/aapt2 dump packagename ~/Downloads/NonSIMCC-151-app-release-signed.apk
com.A.B
If you just want to know package name, run adb logcat, launch the activity you want , you will get a hint on the package name.
Another solution is to use aapt list and use sed to parse through that:
aapt list -a $PATH_TO_YOUR_APK | sed -n "/^Package Group[^s]/s/.*name=//p"
I think the best and simplest way to extract only the package name in Linux is
aapt dump badging <APK_path> | grep package | sed -r "s/package: name='([a-z0-9.]*)'.*/\1/"
Explanation:
AAPT extracts the APK information
Grep "package" to keep only the line about the package information
Make sed replace the whole line with the package name only using the following regex: package: name='([a-z0-9.]*)'.* and replacing with the first (and only) matching group.
There's a very simple way if you got your APK allready on your Smartphone. Just use one of these APPs:
Package Name Viewer Apps
To use this in batch scripting it's handy to have the script return just the package name (e.g. for uninstalling an app when you have the APK).
Here's the script I use:
# extract the android package id from a built apk file
# usage ./getPackageName.sh <path-to-apk>
line=`aapt dump badging "$1" | grep package:\ name`
# above returns:
# package: name='com.calvium.myapp' versionCode='1' versionName='1.0'
if [[ $line =~ name=\'(.+)\'\ versionCode ]]; then
echo ${BASH_REMATCH[1]}
else
echo "Failed to find package name"
exit 1
fi
available on gist
So you could write:
adb uninstall `./getPackageName.sh file.apk`
You can extract AndroidManifest.xml from the APK, remove all NULL bytes, skip everything until after the string 'manifest', and then you are at a length byte followed by the package name (and what comes after it). For the difficult task I use the great GEMA tool, so the command looks like this:
7z e -so MyApp.apk AndroidManifest.xml | gema '\x00=' | gema -match 'manifest<U1><U>=#substring{0;#char-int{$1};$2}'
Of course, you can use any other tool to do the filtering.
For Windows following worked for me:
:: // Initializing variables
SET adb="C:\Users\<User name>\AppData\Local\Android\Sdk\platform-tools\adb"
SET aapt="C:\Users\<User name>\AppData\Local\Android\Sdk\build-tools\22.0.0\aapt"
SET APKPath=C:\Users\<User name>\Desktop\APK\Instant_Instal\
CD %APKPath%
:: // Searching for apk file and storing it
FOR /F "delims=" %%f IN ('dir /S /B *.apk') DO SET "APKFullPath=%%f"
SET apk=%APKFullPath%
:: // Command adb install apk, run apk
%adb% install %apk%
:: // Fetching package name from apk
%aapt% dump badging %APKFullPath% | FIND "package: name=" > temp.txt
FOR /F "tokens=2 delims='" %%s IN (temp.txt) DO SET pkgName=%%s
del temp.txt
:: // Launching apk
%adb% shell monkey -p %pkgName% -c android.intent.category.LAUNCHER 1
pause
Note
Please edit the paths of adb, aapt, APKPath according to the paths of adb, aapt, and the apk location in your system.
Working:
Here I have added the apk in a folder on Desktop "\Desktop\APK\Instant_Instal\".
The command %adb% install %apk% installs the application if the device is connected.
This %aapt% dump badging %APKFullPath% | FIND "package: name=" > temp.txt fetches package name and a few other details like version etc. of the apk and stores in a temp.txt file in same location as that of the apk.
FOR /F "tokens=2 delims='" %%s IN (temp.txt) DO SET pkgName=%%sextracts the package name and assigns topkgName` variable
Finally %adb% shell monkey -p %pkgName% -c android.intent.category.LAUNCHER 1 launches the app.
In essence the above code installs the apk from given location in desktop "Desktop\APK\Instant_Instal\" to the device and launches the application.
You can get the package name programmatically by :
packageManager.getPackageArchiveInfo(apkFilePath, 0)?.packageName
you can instal Package_Name_Viewer.apk on your emulator and next you can see package name of all instaled app on your emulator.
I also tried the de-compilation thing, it works but recently I found the easiest way:
Download and install Appium from Appium website
Open Appium->Android setting, choose the target apk file. And then you get everything you want, the package info, activity info.
As I don't was able to find the package name in the .apk file with editor (like suggested above), I have checked the functions in the App "ES Datei Explorer" / "ES File Explorer" (free version) that I had installed already.
In this tool, the package name is showed properly.
As I think a good file explorer should not be missing on a phone, I suggest to use this tool (if you already have installed the apk on an mobile and have to know the package name).
If you want to read the package name of a typical APK file in your app, there's an easy way to analyze the PackageInfo:
fun getAPKPackageName(apkFile: File?): String? {
if (apkFile == null || !apkFile.isFile || !apkFile.exists()) return null
val apkFilePath = apkFile.absolutePath
if (apkFilePath.isNullOrEmpty()) return null
val packageManager = App.context.packageManager ?: return null
val packageInfo = packageManager.getPackageArchiveInfo(apkFilePath, 0) ?: return null
return packageInfo.packageName
}

Sift Implementation in Vlfeat

I am using the Sift implementation by Vlfeat.org. It has the follwing function which is supposed to save the features to a file.
def process_image(imagename,resultname,params="--edge-thresh 10 --peak-thresh 5"):
""" process an image and save the results in a file"""
if imagename[-3:] != 'pgm':
#create a pgm file
im = Image.open(imagename).convert('L')
im.save('tmp.pgm')
imagename = 'tmp.pgm'
cmmd = str("sift "+imagename+" --output="+resultname+
" "+params)
os.system(cmmd)
print 'processed', imagename, 'to', resultname
Here how the line "os.system(cmmd)" is supposed to write the results in a file?
I am on an ubuntu machine and if I execute "sift" as command in terminal, I am getting the result as "not found". On linux, which process is this command trying to invoke? I need to save these Sift features into a file so that later I can use it to create Bag of Words descriptor for clustering.
A similar sift implementation at https://github.com/jesolem/PCV/blob/master/PCV/localdescriptors/sift.py also uses the same line to save the result into file.
On linux, which process is this command trying to invoke?
This refers to the command-line tool provided by vlfeat (see vlfeat/src/sift.c):
$ ./sift
Usage: ./sift [options] files ...
Options include:
--verbose -v Be verbose
--help -h Print this help message
--output -o Specify output file
...
You can either use the binary distribution from vlfeat download page (see bin/glnxa64/sift for Linux 64-bit), or directly clone the repo and compile it from sources.
Make sure to adjust the path with cmmd = str("/path/to/sift " ...) or install (= copy it) under a common path like /usr/local/bin.

Downloading file from online database using bash script

I want to download some files from an online database, but it does not allow me to download all the files at once. Instead it offers to download a file for a searched keyword. Because I have more than 20000 keywords, it's not feasible for me.
For example, I want to download whole information about miRNA-mRNA interaction from SarBase, but it does not offer an option to download all of them at once.
I wonder, how can I download it by writing some scripts. Can anybody help me?
Make a file called getdb.sh.
#!/bin/bash
echo "Download keywords in kw.txt."
for kw in $(cat kw.txt)
do
curl http://www.mirbase.org/cgi-bin/get_seq.pl?acc=$kw > $kw.txt
done
Create another file called kw.txt:
MI0000342
MI0000343
MI0000344
Then run this
$ chmod +x getdb.sh
$ ./getdb.sh
Download keywords in kw.txt.
$ ls -1 *.txt
kw.txt
MI0000342.txt
MI0000343.txt
MI0000344.txt
another way
cat kw.txt |xargs -i curl -o {}.txt http://www.mirbase.org/cgi-bin/get_seq.pl?acc={}

How to check which files are being ignored because of .hgignore?

I'm quite often concerned that my hgignore file may be excluding important files. For example I just noticed that I was excluding all .exe files which excluded some little executable tools which should be kept with the source. It was a simple change to include them but makes me worried that the rules could have un-intended consequences.
Is there a way to view a list of all the files which are not being tracked due to the .hgignore file? Just so I can periodically review the list to check I'm happy with it.
The command hg status -i does exactly that.
#Jon beat me to the punch with the right answer, but its worth nothing that along with status -i, there is:
hg status -m (only modified files)
hg status -a (only files that were added)
hg status -r (only files that were removed)
hg status -d (only files that were deleted)
hg status -u (all non-tracked files)
hg status -c (files with no changes, ie. "clean")
hg status -A (all files, ie, everything)
If you want to do manual inspection on the file names, then use the -i/--ignored flag to status:
$ hg status -i
I ignored file.exe
If you want the file names alone, then use -n/--no-status to suppress the I status code printed in front of each filename:
$ hg status -n -i
ignored file.exe
If you need to process the files with xargs, then use the -0/--print0 flag in addition:
$ hg status -n -0 | xargs -0 touch
That will take care of handling spaces correctly — with using -0, there is a risk that you'll end up treating ignored file.exe as two files: ignored and file.exe since shells normally split on spaces.
The above commands show you untracked files matching .hgignore. If you want to solve the related problem of finding tracked files matching .hgignore, then you need to use a fileset query. That looks like this:
$ hg locate "set:hgignore()"
You can use filesets with all commands that operate on files, so you can for example do:
$ hg forget "set:hgignore()"
to schedule the files found for removal (with a copy left behind in your working copy).
Yes, it is Possible.
If You're using smth like TortoiseHg, You can select what files You wanna see.
Here's a sample

Resources