* User management: Honor rights from current logged in user
* Group management now available. But no relation check yet.
* User management: Additional groups
+ * Page title available
+ * Deletion of a collection removes the storage too
+ * IMDB Tool. Order of save to field now A-Z
+ * Documentation for tools
+ * Documentation for tool imdbweb grabber. Default config added.
1.0 - Castle 20210106
* First usable version
Change PATH_ABSOLUTE to you installation path and PATH_WEB_STORAGE relative to your webroot.
+Copy config-imdb.php.default to config-imdb.php. Read the tools.txt and tool-imdbweb.txt and make wanted changes
+to that file
+
4. Move files
Move the content of webclient folder to your webspace. Make sure the location matches
the PATH_ABSOLUTE config in config.php file
--- /dev/null
+IMDB web parser tool
+
+It provides easy searching for a movie entry within https://www.imdb.com.
+Creating a new one with the selected fields or updating an existing one.
+
+It uses: https://github.com/FabianBeiner/PHP-IMDB-Grabber with some modifications
+
+You can search for words or the exact imdb id, which is in tt* format of an entry url.
+It searches for movies only.
+
+Which fields are available for you to select, are configured in the config.imdbweb.php file to make it
+easier since not every field the tool provides are needed.
+Follow the comments in the file for more details.
--- /dev/null
+Each collection can have additional tools. The availability is configured in collection management.
+
+A tool needs an DB entry in _tool and matching files in view/THEME/tool/.
+Filenames are tool-ACTION.html|php
+A option configuration file config/config-ACTION.php
+A documentation is a must.
+
+As a base the provided imdbweb parse is already included. It makes it possible to search for a movie within
+https://www.imdb.com and let you pick with information should be saved into the entry.
# Deletion of config definition
The definition of USER_DEFAULT_RIGHTS_STRING can be removed from config file.
+# New config file
+Copy config/config-imdbweb.php.default to config/config-imdbweb.php
+See too-imdbweb.txt documentation for more information.
+
# DB changes. Run each line against your bibliotheca DB.
# Replace #REPLACEME# with your table prefix. Default is bib
UPDATE `#REPLACEME#_menu` SET `rights` = 'rw-rw----' WHERE `bib_menu`.`id` = 10;
--- /dev/null
+<?php
+/**
+ * Options for the grabber
+ *
+ * TOOL_IMDBWEB_SEARCH can be 'movie','tv','episode','game','all'. Default is movie
+ * TOOL_IMDBWEB_FIELDS is an array to define which fields from IMDB are displayed for selection
+ * an empty array() shows all.
+ * getAka, getAkas, getAspectRatio, getAwards, getBudget, getCast, getCastAndCharacter, CastAndCharacterAsUrl,
+ * getCastAsUrl, getCertification, getColor, getCompany, getCompanyAsUrl, getCountry, getCountryAsUrl,
+ * getCreator, getCreatorAsUrl, getDescription, getDirector, getDirectorAsUrl, getGenre, getGenreAsUrl,
+ * getGross, getLanguage, getLanguageAsUrl, getLocation, getLocationAsUrl, getLocations, getMpaa, getPlot,
+ * getPlotKeywords, getPoster, getRating, getRatingCount, getReleaseDate, getReleaseDates, getRuntime,
+ * getSeasons, getSeasonsAsUrl, getSoundMix, getTagline, getTitle, getTrailerAsUrl, getUrl, getUserReview,
+ * getVotes, getWriter, getWriterAsUrl, getYear
+ * TOOL_IMDBWEB_BROWSERSTRING a current browser agent string. Should be updated from time to time. See default config file.
+ * TOOL_IMDBWEB_BROWSER_ACCEPT_LANG should define in which language the content returns
+*/
+define('TOOL_IMDBWEB_SEARCH','movie');
+define('TOOL_IMDBWEB_FIELDS', array('getCast','getDescription', 'getDirector', 'getGenre', 'getPlot', 'getRating', 'getRuntime','getTitle', 'getWriter', 'getYear'));
+
+define('TOOL_IMDBWEB_BROWSER_AGENT','Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0');
+define('TOOL_IMDBWEB_BROWSER_ACCEPT','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8');
+define('TOOL_IMDBWEB_BROWSER_ACCEPT_LANG','en-US,en;q=0.5');
/**
* Set the preferred language for the User Agent.
*/
- private $IMDB_LANG = 'en-US,en;q=0.9';
+ private $IMDB_BROWSER_LANG;
+
+ /**
+ * @var string The accept string for curl call
+ */
+ private $IMDB_BROWSER_ACCEPT;
+
+ /**
+ * @var string The user-agent string fpr curl call
+ */
+ private $IMDB_BROWSER_AGENT;
/**
* Define the timeout for cURL requests.
*/
private $sSearchFor = 'all';
+ /**
+ * @var array The fields to return at getAll
+ */
+ private $_showFields;
+
/**
* IMDB constructor. Can now set some options
*
* int iCache Custom cache time in minutes.
* string sSearchFor What type to search for?
* string storage Where to store data. Absolute path
- * boolean debug Show depubg messages or not
+ * boolean debug Show debug messages or not
*/
public function __construct($options) {
$this->sSearchFor = $options['sSearchFor'];
}
}
+
+ $this->IMDB_BROWSER_AGENT = $options['browserAgent'];
+ $this->IMDB_BROWSER_LANG = $options['browserLang'];
+ $this->IMDB_BROWSER_ACCEPT = $options['browserAccept'];
+
+ $this->_showFields = array();
+ if(isset($options['showFields']) && !empty($options['showFields'])) {
+ $this->_showFields = $options['showFields'];
+ }
}
$aData = [];
foreach (get_class_methods(__CLASS__) as $method) {
if (substr($method, 0, 3) === 'get' && $method !== 'getAll' && $method !== 'getCastImages') {
+ if(!empty($this->_showFields) && !in_array($method,$this->_showFields)) continue;
$aData[$method] = [
'name' => ltrim($method, 'get'),
'value' => $this->{$method}(),
curl_setopt_array(
$oCurl,
[
- CURLOPT_BINARYTRANSFER => ($bDownload ? true : false),
CURLOPT_CONNECTTIMEOUT => $this->IMDB_TIMEOUT,
CURLOPT_ENCODING => '',
CURLOPT_FOLLOWLOCATION => 0,
CURLOPT_FRESH_CONNECT => 0,
CURLOPT_HEADER => ($bDownload ? false : true),
CURLOPT_HTTPHEADER => [
- 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- 'Accept-Charset: utf-8, iso-8859-1;q=0.5',
- 'Accept-Language: ' . $this->IMDB_LANG,
+ 'Accept: '.$this->IMDB_BROWSER_ACCEPT,
+ 'Accept-Language: ' . $this->IMDB_BROWSER_LANG,
],
CURLOPT_REFERER => 'https://www.imdb.com',
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_TIMEOUT => $this->IMDB_TIMEOUT,
- CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0',
+ CURLOPT_USERAGENT => $this->IMDB_BROWSER_AGENT,
CURLOPT_VERBOSE => 0,
]
);
* Get the fields for currently loaded collection.
*
* @param bool $refresh True to reload from DB
+ * @param bool $sortAZ
* @return array
*/
- public function getExistingFields($refresh=false) {
+ public function getExistingFields($refresh=false, $sortAZ=false) {
if($refresh === false && !empty($this->_cacheExistingSysFields)) {
return $this->_cacheExistingSysFields;
}
$queryStr = "SELECT `cf`.`fk_field_id` AS id, `sf`.`type`, `sf`.`displayname`, `sf`.`identifier`,
`sf`.`createstring`
FROM `".DB_PREFIX."_collection_fields_".$this->_collectionId."` AS cf
- LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`
- ORDER BY `cf`.`sort`";
+ LEFT JOIN `".DB_PREFIX."_sys_fields` AS sf ON `cf`.`fk_field_id` = `sf`.`id`";
+ if($sortAZ === true) {
+ $queryStr .= " ORDER BY `sf`.`displayname`";
+ }
+ else {
+ $queryStr .= " ORDER BY `cf`.`sort`";
+ }
if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
try {
$query = $this->_DB->query($queryStr);
*/
require_once 'lib/imdbwebparser.class.php';
+if(file_exists(PATH_ABSOLUTE.'/config/config-imdbweb.php')) {
+ require_once 'config/config-imdbweb.php';
+}
$IMDB = new IMDB(array(
- 'sSearchFor' => 'movie',
+ 'sSearchFor' => TOOL_IMDBWEB_SEARCH,
+ 'showFields' => TOOL_IMDBWEB_FIELDS,
'storage' => PATH_SYSTEMOUT,
+ 'browserAgent' => TOOL_IMDBWEB_BROWSER_AGENT,
+ 'browserLang' => TOOL_IMDBWEB_BROWSER_ACCEPT_LANG,
+ 'browserAccept' => TOOL_IMDBWEB_BROWSER_ACCEPT,
'debug' => false
));
// prepare fields to save into selection
// create one time and then reuse it
-$collectionFields = $ManangeCollectionsFields->getExistingFields();
+$collectionFields = $ManangeCollectionsFields->getExistingFields(false, true);
if(!empty($collectionFields)) {
foreach ($collectionFields as $k=>$v) {
$TemplateData['saveToSelection'] .= "<option value='".$k."'>".$v['displayname']."</option>\n";