[add] parse local isbn metadata
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							parent
							
								
									3057b86002
								
							
						
					
					
						commit
						c66a6c8499
					
				@ -1,6 +1,7 @@
 | 
				
			|||||||
package metadata
 | 
					package metadata
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"regexp"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/PuerkitoBio/goquery"
 | 
						"github.com/PuerkitoBio/goquery"
 | 
				
			||||||
@ -14,11 +15,33 @@ func getEPUBMetadata(filepath string) (*MetadataInfo, error) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	rf := rc.Rootfiles[0]
 | 
						rf := rc.Rootfiles[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &MetadataInfo{
 | 
						parsedMetadata := &MetadataInfo{
 | 
				
			||||||
		Title:       &rf.Title,
 | 
							Title:       &rf.Title,
 | 
				
			||||||
		Author:      &rf.Creator,
 | 
							Author:      &rf.Creator,
 | 
				
			||||||
		Description: &rf.Description,
 | 
							Description: &rf.Description,
 | 
				
			||||||
	}, nil
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Parse Possible ISBN
 | 
				
			||||||
 | 
						if rf.Source != "" {
 | 
				
			||||||
 | 
							replaceRE := regexp.MustCompile(`[-\s]`)
 | 
				
			||||||
 | 
							possibleISBN := replaceRE.ReplaceAllString(rf.Source, "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// ISBN Matches
 | 
				
			||||||
 | 
							isbn13RE := regexp.MustCompile(`(?P<ISBN>\d{13})`)
 | 
				
			||||||
 | 
							isbn10RE := regexp.MustCompile(`(?P<ISBN>\d{10})`)
 | 
				
			||||||
 | 
							isbn13Matches := isbn13RE.FindStringSubmatch(possibleISBN)
 | 
				
			||||||
 | 
							isbn10Matches := isbn10RE.FindStringSubmatch(possibleISBN)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if len(isbn13Matches) > 0 {
 | 
				
			||||||
 | 
								isbnIndex := isbn13RE.SubexpIndex("ISBN")
 | 
				
			||||||
 | 
								parsedMetadata.ISBN13 = &isbn13Matches[isbnIndex]
 | 
				
			||||||
 | 
							} else if len(isbn10Matches) > 0 {
 | 
				
			||||||
 | 
								isbnIndex := isbn10RE.SubexpIndex("ISBN")
 | 
				
			||||||
 | 
								parsedMetadata.ISBN10 = &isbn10Matches[isbnIndex]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return parsedMetadata, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func countEPUBWords(filepath string) (int64, error) {
 | 
					func countEPUBWords(filepath string) (int64, error) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user