LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-22-2017, 08:14 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
Command line to output EPUB title description?


Hello,

I have downloaded from the free www.Gutenberg.org several Sci-Fi books about Mars:

herewith a cool list about Mars Sci-Fi:
pg21873-images.epub
pg23731-images.epub
pg24104-images.epub
pg27400-images.epub
pg32284-images.epub
pg32436-images.epub
pg32664-images.epub
pg4300-images.epub
pg45530-images.epub
pg50783-images.epub
pg62-images.epub
pg64-images.epub

There are awaiting on the apache web for sci-fi reading.

But well, in order to get an index.html file with the title of the book, it would be great to have a list with titles.

Would you maybe know a possible command line to output EPUB title description? Maybe even author(s).

Thank you
 
Old 07-22-2017, 08:39 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
EPUB embeds a lot of metadata. The utility exiftool can extract just about any metadata found in a file for you. That should include title, author, and many other fields in EPUB. See its man page for the million or so options.

Last edited by Turbocapitalist; 07-22-2017 at 08:41 AM.
 
Old 07-22-2017, 09:50 AM   #3
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Turbocapitalist View Post
EPUB embeds a lot of metadata. The utility exiftool can extract just about any metadata found in a file for you. That should include title, author, and many other fields in EPUB. See its man page for the million or so options.

I installed exiftool

I did create a C file that does read the opendir list of files,
while popen it will exiftool to a file.


Many thanks !! mission completed.
https://pastebin.com/raw/PAwaVzQy

Part of the source code is here.

Code:

            ////////////////// advanced mechanism to create epub index
            if ( foundcode == 0 )
            if ( fetchline[0] == '!' )
            if ( fetchline[1] == 'e' )
            if ( fetchline[2] == 'x' )
            if ( fetchline[3] == 'i' )
            if ( fetchline[4] == 'f' )
            if ( fetchline[5] == '{' )
            {
 	      fputs( "<a href=\"" , fp5 );
 	      fputs( strdelimit( fetchline,  '{' ,'}' ,  1 ) , fp5 );
  	      fputs( "\">  ", fp5 );
 	      fputs( strdelimit( fetchline,  '{' ,'}' ,  1 ) , fp5 );
  	      fputs( " </a> <br> \n", fp5 );
                    // ok just to copy-paste easy
                    char linereadtmp[PATH_MAX];
                    char lineread[PATH_MAX];
                    char exifline[PATH_MAX];
                    FILE *fp1;
 	            strncpy( exifline, "",  PATH_MAX );
                    strncat( exifline , " exiftool \"" , PATH_MAX - strlen( exifline ) -1 );
                    strncat( exifline , strdelimit( fetchline,  '{' ,'}' ,  1 ) , PATH_MAX - strlen( exifline ) -1 );
                    strncat( exifline , "\" " , PATH_MAX - strlen( exifline ) -1 );
           	    //
                    printf( " =>Command (ext): %s\n", exifline );
                    fp1 = popen( exifline , "r");
                    while( !feof(fp1) ) 
                    {
                        fgets(linereadtmp, PATH_MAX, fp1); 
                        strncpy( lineread, strrlf(linereadtmp) , PATH_MAX );
                        if ( !feof(fp1) )
			{
  	                   fputs( lineread , fp5 );
  	                   fputs( "<br>\n" , fp5 );
		        }
                    }
                    pclose( fp1 );
 	            fputs( "<br>\n" , fp5 );
  	            foundcode = 1;
            }
 
Old 07-22-2017, 10:04 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Interesting approach.

You could use it natively in perl. exiftool is just a front-end for the CPAN module Image::ExifTool. However, it isn't one of the modules that is build on top of C libraries, as far as I can tell, but there might be a corresponding C library out there so if you are using C you could use a native library instead.
 
Old 07-22-2017, 10:11 AM   #5
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Turbocapitalist View Post
Interesting approach.

You could use it natively in perl. exiftool is just a front-end for the CPAN module Image::ExifTool. However, it isn't one of the modules that is build on top of C libraries, as far as I can tell, but there might be a corresponding C library out there so if you are using C you could use a native library instead.
I do not like large/vast installation, non portable, programming environment. I prefer Assembler (for 1 archi) or C at max.

next step would be to add lib in the C code.

but first, some reading and sipping

Last edited by Xeratul; 07-22-2017 at 10:13 AM.
 
Old 07-22-2017, 10:17 AM   #6
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by Xeratul View Post
I do not like large/vast installation, non portable, programming environment. I prefer Assembler or C at max.
That's fine. If you search you can find several EXIF libraries for C so you won't have to use C to call a wrapper to perl which is in turn using a CPAN module. You can do it all in C from top to bottom that way.
 
Old 07-22-2017, 10:27 AM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by Turbocapitalist View Post
That's fine. If you search you can find several EXIF libraries for C so you won't have to use C to call a wrapper to perl which is in turn using a CPAN module. You can do it all in C from top to bottom that way.
the problem is that if I use the exif library into my code, then, it won't be universal anylonger.

What about porting on mac, solaris,... ?

more reading about unimark: https://github.com/spartrekus/Unimark
example : https://github.com/spartrekus/Unimar...t-example2.pdf
Unimark does also work to create html with webmark.c

Last edited by Xeratul; 07-22-2017 at 10:28 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Command output to file on the same line ulto Linux - Newbie 5 02-10-2015 10:42 PM
[SOLVED] Command Line Output mp85 Linux - Newbie 3 04-25-2014 10:46 AM
Stat command output description jackloo Linux - Newbie 2 09-28-2007 08:31 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration