Refracta Development, Scripts, etc.
Post a reply
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## youtube2what

Tue Jan 15, 2013 5:35 pm

I rewrote the youtube2*.sh scripts as a single script that asks you for the target format. This is meant to replace the four or five separate scripts that are in /usr/local/bin, only two of which are used in the Thunar custom actions. It'll work from a terminal, too. Name the file(s) you want to convert on the command line.
This might be lined up better than the code block below - https://gist.github.com/4540352

Code:
  `#!/usr/bin/env bash
  # youtube2what
  [[ $# -ne 0 ]] || { echo "
  Missing argument.
  You need to name at least one video file.
  " ; exit 1 ; }
  # if yad is installed, use in preference
  if [[ -f /usr/bin/yad ]]; then
  DIALOG="yad"
  INFO="image=gtk-dialog-info"
  QUESTION="image=gtk-dialog-question"
  WARNING="image=gtk-dialog-warning"
  ERROR="image=gtk-dialog-error"
  #buttons
  BUTTON0="button"
  BUTTON1="button"
  BUTTON0NUM=":0"
  BUTTON1NUM=":1"
  #cancel button always returns 1 as $?
  #ok button always returns 0 as $?
  #ok is default (highlighted)
  #buttons in yad dialog window may show reversed from zenity window, e.g.
  #yad: ok -- cancel (0 -- 1)
  #zenity: cancel -- ok (1 -- 0)
  elif [[ -f /usr/bin/zenity ]]; then
  # use zenity
  DIALOG="zenity"
  INFO="info"
  QUESTION="question"
  WARNING="warning"
  ERROR="error"
  #buttons
  BUTTON0="ok-label"
  BUTTON1="cancel-label"
  BUTTON0NUM=""
  BUTTON1NUM=""
  else
  nodialog="yes"
  fi
  if [[ $nodialog = "yes" ]]; then
  while true ; do
  echo "
  Enter one of the following formats:
  mp3 flac ogg avi mp4 mkv
  "
  read format
  done
  else
  format=$($DIALOG --entry --title="Choose format" --text="Enter one of the following target formats:
  mp3 flac ogg avi mp4 mkv")
  fi
  case "$format" in
  mp3)
  for MOVIE in "$@" ; do
  AUDIOOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')
  ffmpeg -i "$MOVIE" -f mp3 "$AUDIOOUT".mp3
  done ;;
  flac)
  for MOVIE in "$@" ; do
  AUDIOOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')
  ffmpeg -i "$MOVIE" -f flac "$AUDIOOUT".flac
  done ;;
  ogg)
  for MOVIE in "$@" ; do
  AUDIOOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')
  ffmpeg -i "$MOVIE" -f ogg "$AUDIOOUT".ogg
  done ;;
  avi)
  for MOVIE in "$@" ; do
  VIDOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')
  ffmpeg -i "$MOVIE" -b 798k -ab 128k "$VIDOUT".avi
  done ;;
  mp4)
  for MOVIE in "$@" ; do
  VIDOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')
  ffmpeg -i "$MOVIE" -acodec copy -vcodec copy "$VIDOUT".mp4
  done ;;
  mkv)
  for MOVIE in "$@" ; do
  VIDOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')
  ffmpeg -i "$MOVIE" -acodec copy -vcodec copy "$VIDOUT".mkv
  done ;;
  *) if [[ $nodialog = "yes" ]]; then
  echo "
  Unsupported format. Try one of these next time:
  mp3 flac avi mp4 mkv
  "
  exit 1
  else
  $DIALOG --$ERROR --title=Error! --text="Unsupported format. Try one of these next time\:
  mp3 flac ogg avi mp4 mkv "
  exit 1
  fi
  esac
  exit 0
  `

anticapitalista

- anticapitalista
- Posts: 64
- Joined: Wed May 09, 2012 10:49 am

## Re: youtube2what

Tue Jan 15, 2013 11:32 pm

Only to mention that you may wish to include youtube-viewer in Refracta. It comes in cli and gui and allows users to search and play youtube videos without a browser and without having to download the files.
https://github.com/trizen/youtube-viewer
antiX has wheezy compatible debs. (I hope that they will work on wheezy based and later Debian and its derivatives.)
http://www.daveserver.info/antiX/main/
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: youtube2what

Wed Jan 16, 2013 12:27 am

Couldn't install the deb...

Code:
  `$ sudo gdebi youtube-viewer_0.0.1_i386.deb
  ...
  Package: youtube-viewer-antix
  Version: 0.0.1
  Architecture: i386
  ...
  Failed to open the software package
  The package might be corrupted or you are not allowed to open the file. Check the permissions of the file.
  `

I tried downloading the file a second time, but that didn't help.
Edit: Tried this on refracta-wheezy-beta6, not sid.
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: youtube2what

Wed Jan 16, 2013 2:38 am

Don't know anything about gdebi. In an old but maintained wheezy install here:

Code:
  `dpkg -i youtube-viewer_0.0.1_i386.deb`

at first gives dependency errors libgtk2-perl libyaml-perl antix-goodies
apt-get -f install sorted the first two
Then manual install of antix-goodies (not yet seen what that actually is) from the same repo and ... it works, I can do a search and the chosen clip opens in mplayer, picture and sound.
I know "minitube" is also available but has heavy-duty qt4 deps. Now, I can do youtube with no browser nor bloat. I will be very pleased to see this work without adobe flash.
I don't know why (or if) it shouldn't work in a clean Refracta, will find out later.
Thanks anticapitalista
EDIT
antix-goodies (although they seem useful scripts) is not essential, I rebuilt the youtube-viewer deb with that removed from the contol file. Only libyaml-perl (205k installed) was required first to "dpkg-i" youtube-viewer to an up-to-date, clean, nonpersistent Refracta live session (flashplugin not installed)
youtube-viewer installed size is marked "868" (kb)
Download (right click menu) works. What also worked for my "test" download clip is fsmithred's script "youtube2what", in all formats listed in the menu. Thanks fsmithred.
BTW the ogg conversion opened by default in gnome-mplayer. It would not play at all in deadbeef.
Last edited by dzz on Wed Jan 16, 2013 4:56 pm, edited 1 time in total.
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: youtube2what

Wed Jan 16, 2013 2:27 pm

youtube-viewer installs but won't work in squeeze

Code:
  `$ gtk-youtube-viewer
  Can't locate WWW/YoutubeViewer.pm in @INC (@INC contains: [slash]etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at /usr/bin/gtk-youtube-viewer line 35.`

fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: youtube2what

Wed Jan 16, 2013 3:30 pm

Yes, it works in beta6. I missed the message about antix-goodies. Pretty cool. Thanks, anti. Is there a way to get it to use gnome-mplayer or to show the controls in mplayer? (I tried editing the mplayer path in Preferences, but that didn't work.)
Using gdebi is like using dpkg, except it automatically pulls in the dependencies. Pretty sure it also has a graphical interface that will come up if you click on a deb file in a file manager. I should probably change the file associations for .deb so that gdebi comes up instead of xarchiver.
Confirmed that youtube2what won't convert video (mp4 in my test) to ogg audio. It will make an ogg video. It also won't convert flac to a working ogg audio file. Maybe I'll axe that script, and use WinFF instead.
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: youtube2what

Wed Jan 16, 2013 4:38 pm

Here's youtube2what again. I replaced the text-entry box with a radiolist, so you don't have to go to the keyboard. Right now, still can't do ogg audio from a video.
https://gist.github.com/e9322c42520f9eac0731
anticapitalista

- anticapitalista
- Posts: 64
- Joined: Wed May 09, 2012 10:49 am

## Re: youtube2what

Wed Jan 16, 2013 5:09 pm

Whoops don't know why I included antix-goodies as a dependency. I have removed it.
Don't know how to get it to use gnome-mplayer or to show the controls in mplayer. I tried using the latest scripts over on githib, they they don't work since they use the latest perl in Experimental.
Anyhow, have fun with it, especially if you have a low powered box.
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: youtube2what

Tue Jan 22, 2013 4:19 pm

> Is there a way to get it to use gnome-mplayer or to show the controls in mplayer?

There is! Works here. Just change, in the preferences,"/usr/bin/mplayer" to "/usr/bin/gnome-mplayer"
Or if you got mplayer-gui intalled (but it's an extra 5MB) "/usr/bin/gmplayer"
You might have to play around with mplayer arguments in preferences or even remove them
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: youtube2what

Tue Jan 22, 2013 4:55 pm

Thanks. I tried putting gnome-mplayer in the preferences before, but I didn't mess with the arguments. Ended up removing them all to get it to work. Removed them from right to left, so I guess I should try putting some back to see if it still works.
Post a reply
Jump to:

Powered by phpBB © phpBB Group.

phpBB Mobile / SEO by Artodia.