Skip to content

Commit

Permalink
environment variable support, preferences file support
Browse files Browse the repository at this point in the history
  • Loading branch information
ColumPaget committed Jun 15, 2017
1 parent c348371 commit e875505
Show file tree
Hide file tree
Showing 144 changed files with 308 additions and 30,914 deletions.
50 changes: 50 additions & 0 deletions Docs/ConfigFile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Movgrab supports a preferences file, either a global one in /etc/movgrab.conf or a per user in ~/.movgrab.conf.

Entries in the file can be:

mediafmt <list of formats in preference order>

A comma-seperated list of preferred file formats and resolutions in preference order, for example:

mediafmt mp4:480x360,mp4,webm,mp3,*



player <content type> <player program>

Entries of this form are used in combination with the '-P auto' command line option. Each entry defines a player program for a particular content-type, as in the following examples.

player audio/mpeg /usr/bin/mpg123
player audio/ogg /usr/bin/ogg123
player application/ogg /usr/bin/ogg123
player * /usr/bin/mplayer



useragent <useragent string>

Sets the useragent string to be used in http/https communications.



proxy <proxy url>

Sets a proxy to be used for network access. The url is in the form <user>:<password>@<proxy type>:<host>:<port>, for example:

socks4:192.168.1.1:8080
socks5:user1:secret@192.168.1.1:5050
http:192.168.6.6:1080



ssllevel <level>

Minium ssl version to use. Options are: ssl, tls, tls1.1, tls1.2 (note, 'ssl' is SSLv3)



sslciphers <cipherlist>

list of permitted ssl ciphers


2 changes: 1 addition & 1 deletion Docs/Proxys.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This is particularly useful in combination with ssh. The ssh command:

will connect to 'myhost' and open a socks4/socks5 proxy service locally on port 5050. Movgrab can then be told:

movgrab -p 127.0.0.1:5050 http://www.youtube.com/?watch=ejfelefffDD
movgrab -p 127.0.0.1:5050 http://www.youtube.com/watch?v=5Lp-rXQqwH8

and all it's communications will be routed through ssh and appear to come from 'myhost'.

Expand Down
2 changes: 1 addition & 1 deletion Docs/Radio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Similarly mpg123 can be used thusly

movgrab -o - 'http://www.triplag.com/webradio/darkpsy/triplag-darkpsy-playlist.asx' | mpg123 -

For ogg-vorbis streams there's "ogg123" which comes as part of the vorbis distrobution.
For ogg-vorbis streams there's "ogg123" which comes as part of the vorbis distribution.

Of course, movgrab can also write the stream to a file,

Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ prefix=/usr/local
bindir=$(prefix)${exec_prefix}/bin
DESTDIR=
FLAGS=$(CFLAGS) -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_LIBZ=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DHAVE_LIBSSL=1 -DHAVE_LIBCRYPTO=1
OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o selectformat.o ehow.o ign.o youtube.o
OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o players.o selectformat.o ehow.o ign.o youtube.o

all: $(OBJ)
@cd libUseful-2.6; $(MAKE)
$(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.6/libUseful-2.6.a
@cd libUseful-2.8; $(MAKE)
$(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.8/libUseful-2.8.a

clean:
@rm -f movgrab *.o libUseful-2.6/*.o libUseful-2.6/*.a libUseful-2.6/*.so
@rm -f movgrab *.o libUseful-2.8/*.o libUseful-2.8/*.a libUseful-2.8/*.so

common.o: common.c common.h
$(CC) $(FLAGS) -c common.c
Expand Down Expand Up @@ -46,6 +46,9 @@ download.o: download.c download.h
display.o: display.c display.h
$(CC) $(FLAGS) -c display.c

players.o: players.c players.h
$(CC) $(FLAGS) -c players.c

selectformat.o: selectformat.c selectformat.h
$(CC) $(FLAGS) -c selectformat.c

Expand Down
11 changes: 7 additions & 4 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ prefix=@prefix@
bindir=$(prefix)@bindir@
DESTDIR=
FLAGS=$(CFLAGS) @DEFS@
OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o selectformat.o ehow.o ign.o youtube.o
OBJ=common.o settings.o containerfiles.o outputfiles.o servicetypes.o extract_text.o download.o display.o players.o selectformat.o ehow.o ign.o youtube.o

all: $(OBJ)
@cd libUseful-2.6; $(MAKE)
$(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.6/libUseful-2.6.a
@cd libUseful-2.8; $(MAKE)
$(CC) $(FLAGS) -o movgrab main.c $(LIBS) $(OBJ) libUseful-2.8/libUseful-2.8.a

clean:
@rm -f movgrab *.o libUseful-2.6/*.o libUseful-2.6/*.a libUseful-2.6/*.so
@rm -f movgrab *.o libUseful-2.8/*.o libUseful-2.8/*.a libUseful-2.8/*.so

common.o: common.c common.h
$(CC) $(FLAGS) -c common.c
Expand Down Expand Up @@ -46,6 +46,9 @@ download.o: download.c download.h
display.o: display.c display.h
$(CC) $(FLAGS) -c display.c

players.o: players.c players.h
$(CC) $(FLAGS) -c players.c

selectformat.o: selectformat.c selectformat.h
$(CC) $(FLAGS) -c selectformat.c

Expand Down
11 changes: 3 additions & 8 deletions common.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#include "common.h"
#include "download.h"

char *FileTypes[]={".flv",".mp3",".mp4",".mov",".wma",".m4a",".m4v",".wmv",".webm",".avi",".3gp","m3u8",NULL};
char *ItemSelectionArg=NULL;
char *NowPlayingFile=NULL;
char *FormatPreference=NULL;
char *FileTypes[]={".flv",".mp3",".ogg",".aac",".mp4",".mov",".wma",".m4a",".m4v",".wmv",".webm",".avi",".3gp","m3u8",NULL};
char *Username=NULL, *Password=NULL;
char *Proxy=NULL;
char *ProgName=NULL, *CmdLine=NULL, *UserAgent=NULL;
int STREAMTimeout=300;
char *ProgName=NULL, *CmdLine=NULL;
STREAM *StdIn=NULL;
int Flags=0;

Expand Down Expand Up @@ -117,7 +112,7 @@ if (STREAMCheckForBytes(StdIn))
{
Tempstr=STREAMReadLine(Tempstr,StdIn);
StripTrailingWhitespace(Tempstr);
if (StrLen(Tempstr))
if (StrValid(Tempstr))
{
ListAddItem(DownloadQueue,CopyStr(NULL,Tempstr));
if (! (Flags & FLAG_QUIET)) fprintf(stderr,"\r\nQUEUED: %s\n",Tempstr);
Expand Down
5 changes: 3 additions & 2 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#define MOVGRAB_COMMON

//This is doable through autoconf, but I'm sick of fighting with it
#define Version "3.0.3"
#define Version "3.1.0"

#include "libUseful-2.6/libUseful.h"
#include "libUseful-2.8/libUseful.h"
#include <string.h>
#include <glob.h>
#include "extract_text.h"
Expand All @@ -30,6 +30,7 @@
#define FLAG_RESUME 65536
#define FLAG_HTTPS 131072
#define FLAG_POST 262144
#define FLAG_PLAYER_AUTO 524288


extern int Type, Flags;
Expand Down
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ LDFLAGS
LIBS
CPPFLAGS
CPP'
ac_subdirs_all='libUseful-2.6'
ac_subdirs_all='libUseful-2.8'

# Initialize some variables set by options.
ac_init_help=
Expand Down Expand Up @@ -1904,7 +1904,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
subdirs="$subdirs libUseful-2.6"
subdirs="$subdirs libUseful-2.8"
ac_ext=c
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AC_INIT([main.c])
VERSION="1.2.1"
AC_SUBST(VERSION)

AC_CONFIG_SUBDIRS([libUseful-2.6])
AC_CONFIG_SUBDIRS([libUseful-2.8])

AC_PROG_CC
AC_LANG_C
Expand Down
45 changes: 14 additions & 31 deletions display.c
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
#include "display.h"
#include "outputfiles.h"
#include "settings.h"

pid_t PlayerPid=0;
char *Player=NULL;
int PlayerLaunchPercent=25;
int DisplayTitleWidth=50;
extern char *CmdLine, *ProgName;


//this shouldn't really be in here, but the decision to launch an player happens in the 'DisplayProgress' function
void LaunchPlayer()
{
char *Tempstr=NULL;

Tempstr=MCopyStr(Tempstr,Player," ",OutputFilesGetFilePath(),NULL);
PlayerPid=Spawn(Tempstr,0,"");

DestroyString(Tempstr);
}


int DisplayAvailableFormats(ListNode *Vars, char *Formats, int ShowSize)
Expand All @@ -26,12 +14,12 @@ char *URL=NULL, *Token=NULL, *TokenID=NULL, *Tempstr=NULL, *ptr;
STREAM *S;
int result=TRUE;

fprintf(stderr, "\nFormats available for this Movie: ");
fprintf(stderr, "\nAvailable media formats: ");

ptr=GetToken(Formats," ",&Token,0);
while (ptr)
{
if (StrLen(Token)) TokenID=MCopyStr(TokenID,"item:",Token,NULL);
if (StrValid(Token)) TokenID=MCopyStr(TokenID,"item:",Token,NULL);

URL=CopyStr(URL,GetVar(Vars,TokenID));

Expand All @@ -45,16 +33,10 @@ if (strcmp(Token,"reference") !=0)
if (S)
{
Tempstr=CopyStr(Tempstr,STREAMGetValue(S,"HTTP:ResponseCode"));
if (strcmp(Tempstr,"403") ==0)
{
fprintf(stderr,"\nERROR: %s response for %s\n",Tempstr,URL);
result=FALSE;
break;
}
else if (strcmp(Tempstr,"200")==0)
if (strcmp(Tempstr,"200")==0)
{
Tempstr=CopyStr(Tempstr,STREAMGetValue(S,"HTTP:Content-length"));
fprintf(stderr, " (%s)",GetHumanReadableDataQty(strtod(Tempstr,NULL),FALSE));
fprintf(stderr, " (%s)",ToMetric(strtod(Tempstr,NULL),FALSE));
STREAMClose(S);
}
}
Expand All @@ -80,7 +62,7 @@ void WriteNowPlayingFile(const char *Title)
{
STREAM *S;

S=STREAMOpenFile(NowPlayingFile, SF_WRONLY | SF_CREAT | SF_TRUNC);
S=STREAMFileOpen(Settings.NowPlayingFile, SF_WRONLY | SF_CREAT | SF_TRUNC);
if (S)
{
STREAMWriteLine(Title, S);
Expand Down Expand Up @@ -116,8 +98,8 @@ if (! (Flags & FLAG_QUIET))
{
if (PrintName)
{
fprintf(stderr,"\nGetting: %s Size: %s Format: %s\n",Title,GetHumanReadableDataQty(DocSize,0), Format);
if (StrLen(NowPlayingFile)) WriteNowPlayingFile(Title);
fprintf(stderr,"\nGetting: %s Size: %s Format: %s\n",Title,ToMetric(DocSize,0), Format);
if (StrValid(Settings.NowPlayingFile)) WriteNowPlayingFile(Title);
}
}

Expand All @@ -127,12 +109,12 @@ BpsStr=CopyStr(BpsStr,"");
if (SpeedStart > 0)
{
Bps=(bytes_read - PrevBytesRead) / (Now-SpeedStart);
BpsStr=MCopyStr(BpsStr,GetHumanReadableDataQty(Bps,0),"/s ",NULL);
BpsStr=MCopyStr(BpsStr,ToMetric(Bps,0),"/s ",NULL);
}

if (DocSize)
{
HUDocSize=CopyStr(HUDocSize,GetHumanReadableDataQty(DocSize,0));
HUDocSize=CopyStr(HUDocSize,ToMetric(DocSize,0));

Percent=bytes_read * 100.0 / DocSize;

Expand All @@ -145,21 +127,22 @@ if (DocSize)
}
else ETAStr=CopyStr(ETAStr,"??:??");

fprintf(stderr," Progress: %0.2f%% %s of %s %s ETA: %s \r",Percent,GetHumanReadableDataQty(bytes_read,0),HUDocSize,BpsStr,ETAStr);
fprintf(stderr," Progress: %0.2f%% %s of %s %s ETA: %s \r",Percent,ToMetric(bytes_read,0),HUDocSize,BpsStr,ETAStr);

}


sprintf(CmdLine,"%s %0.2f%% %s \0",ProgName,Percent,Title);

if ((PlayerPid==0) && (Percent > PlayerLaunchPercent) && (Player)) LaunchPlayer();
}
else
{
if (! (Flags & FLAG_QUIET)) fprintf(stderr," Progress: %s %s \r",GetHumanReadableDataQty((double) bytes_read,0),BpsStr);
if (! (Flags & FLAG_QUIET)) fprintf(stderr," Progress: %s %s \r",ToMetric((double) bytes_read,0),BpsStr);
sprintf(CmdLine,"%s %s \0",ProgName,Title);
}

if ((DocSize == 0) || (Percent > Settings.PlayerLaunchPercent)) LaunchPlayer();

fflush(NULL);
if (Now - SpeedStart > 5)
{
Expand Down
1 change: 0 additions & 1 deletion display.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "common.h"

extern char *Player;
extern int DisplayTitleWidth;

int DisplayAvailableFormats(ListNode *Vars, char *Formats, int ShowSize);
Expand Down
Loading

0 comments on commit e875505

Please sign in to comment.