Page 4 of 4

Re: please is there any way to use TheMovieDb for series?

Posted: 11 Nov 2018, 12:56
by cafevincent
is this close? it says "The current scope already contains a variable of the name eavg"

Code: Select all

-rename
--db
TheMovieDB::TV
--format
"{def season = (any{special ? 0 : s} {s}); def episode = (any{special ? special : e} {e}); def eAddOns = ['append_to_response':'external_ids']; def sAddOns = ['append_to_response':'external_ids,content_ratings']; def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); def epRating = episodeInfo.vote_average; def epImdbId = episodeInfo.external_ids.imdb_id; def sImdbId = seriesInfo.external_ids.imdb_id; def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; def OMDbSeriesInfo = (sImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':sImdbId]) : null; def epOMDbVotes = any{OMDbEpisodeInfo.imdbVotes as int}{null}; def sOMDbVotes = any{OMDbSeriesInfo.imdbVotes.replaceAll(/D/) as int}{null}; def sTvdbId = any{seriesInfo.external_ids.tvdb_id as int}{null}; def tvdbInfo = (sTvdbId != null) ? net.filebot.WebServices.TheTVDB.getSeriesInfo(sTvdbId, Locale.US) : null; def mpaaCountryLIST = ['FI', 'US']; def mpaaRating = any{seriesInfo.content_ratings.results.findAll{r -> mpaaCountryLIST.any{r.iso_3166_1.contains(it)}}.sort().collect{it.rating}.last()}{''}; def ecertifications = net.filebot.WebServices.TheMovieDB.getEpisodeInfo(eAddOns, Locale.US, true).ecertifications; def ecleanNum = ecertifications.findResults{key, value -> value.replaceAll('\\D')}.findAll{it}*.toInteger().findAll{it < 22}; def int eavg = (ecleanNum.sum() / ecleanNum.size()).toDouble().round(); def scertifications = net.filebot.WebServices.TheMovieDB.getSeriesInfo(sAddOns, Locale.US, true).scertifications; def scleanNum = scertifications.findResults{key, value -> value.replaceAll('\\D')}.findAll{it}*.toInteger().findAll{it < 22}; def int eavg = (scleanNum.sum() / scleanNum.size()).toDouble().round(); (allOf{ny}{s00e00}{t}{OMDbEpisodeInfo.Genre}{'c'+any{eavg}{savg}{'NR'}}{'r'+any{OMDbSeriesInfo.imdbRating}{epRating.round(1)}{' '}}{vf}{vc}{ac}{any{epImdbId}{sImdbId}}).join(' ')}"

Re: please is there any way to use TheMovieDb for series?

Posted: 12 Nov 2018, 19:13
by kim
cafevincent wrote: 11 Nov 2018, 12:56 is this close? it says "The current scope already contains a variable of the name eavg"
1. in short = no

2. can you have more then 1 variable named "eavg" on same "level" ?

3. do you see "content ratings (certifications)" on episode level ?
https://developers.themoviedb.org/3/tv- ... de-details

4. why do you change my code and not confirming your changes works in the GUI piece by piece ?

Re: please is there any way to use TheMovieDb for series?

Posted: 12 Nov 2018, 20:26
by cafevincent
kim wrote: 12 Nov 2018, 19:13 1. in short = no

2. can you have more then 1 variable named "eavg" on same "level" ?

3. do you see "content ratings (certifications)" on episode level ?
https://developers.themoviedb.org/3/tv- ... de-details
just got to realizing both those things just before noticing this post, believe it or not.. you gave me just enough time for self-reflection. sorry :oops:, here is my new streamlined one I'm trying to debug. it looks a lot better but it's also broken, saying "unexpected token: key". I don't know what to do about it.

Code: Select all

-rename
--db
TheMovieDB::TV
--format
"def season = (any{special ? 0 : s} {s}); def episode = (any{special ? special : e} {e}); def eAddOns = ['append_to_response':'external_ids']; def sAddOns = ['append_to_response':'external_ids,content_ratings']; def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); def epRating = episodeInfo.vote_average; def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); def certifications = net.filebot.WebServices.TheMovieDB.getSeriesInfo(series, Locale.US, true).certifications; def cleanNum = certifications.findResults{key, value -> value.replaceAll('\\D')}.findAll{it}*.toInteger().findAll{it < 22}; def int avg = (cleanNum.sum() / cleanNum.size()).toDouble().round(); def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; def epImdbId = episodeInfo.external_ids.imdb_id; (allOf{ny}{s00e00}{t}{OMDbEpisodeInfo.Genre}{'c'{avg}}{'r'{OMDbEpisodeInfo.imdbRating}}{vf}{vc}{ac}{epImdbId}).join(' ')}"
kim wrote: 12 Nov 2018, 19:13 4. why do you change my code and not confirming your changes works in the GUI piece by piece ?
thanks for the tip.

Re: please is there any way to use TheMovieDb for series?

Posted: 17 Nov 2018, 17:34
by kim

Code: Select all

{
def sAddOns = ['append_to_response':'external_ids,content_ratings']; 
def seriesInfo = net.filebot.WebServices.TheMovieDB.request(\u0022tv/${id}\u0022, sAddOns, Locale.US); 
def scleanNum = seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('\\D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}; 
int savg = (scleanNum.sum().div(scleanNum.size())).toDouble().round(); 
}

Re: please is there any way to use TheMovieDb for series?

Posted: 18 Nov 2018, 16:55
by cafevincent
still "unexpected token: key". it looks like the "{key, value -> " bit divides each cert entry into alphabetical markings (key, unused) and numerals (value), yet is somehow is not recognized as valid word to use here? god I wish I knew some java right now.

Re: please is there any way to use TheMovieDb for series?

Posted: 18 Nov 2018, 17:09
by kim
where is the { ?

Code: Select all

--format
"def season

Code: Select all

--format
"{def season

Re: please is there any way to use TheMovieDb for series?

Posted: 01 Dec 2018, 11:30
by cafevincent
I'm sorry but adding the missing { did not help much, it now produces an empty filename with extension only.

Code: Select all

Rename episodes using [TheMovieDB]
Fetching episode data for [StartUp]
Stripping invalid characters from new path: ""
[MOVE] from [E:\TEMP\vr1507079\StartUp 2016 S03E01 Rebranding 1080p.mkv] to [E:\TEMP\vr1507079\.mkv]
Processed 1 files
I don't know how to test this "piece by piece" either or what else to do anymore. I don't have a near complete working code with these features I could try adjusting in tiny increments, I'm just struggling to gather a simple enough code correctly from all we've talked about. my script cluster development has been in limbo ever since, sorry. I'm desperate, is there nobody I could hire to do this because I'm not getting any smarter...

Code: Select all

-rename
--db
TheMovieDB::TV
--format
"{def season = (any{special ? 0 : s} {s}); def episode = (any{special ? special : e} {e}); def eAddOns = ['append_to_response':'external_ids']; def sAddOns = ['append_to_response':'external_ids,content_ratings']; def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); def epRating = episodeInfo.vote_average; def seriesInfo = net.filebot.WebServices.TheMovieDB.request(\u0022tv/${id}\u0022, sAddOns, Locale.US); def certifications = net.filebot.WebServices.TheMovieDB.getSeriesInfo(series, Locale.US, true).certifications; def cleanNum = seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('\\D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}; def int avg = (cleanNum.sum().div(cleanNum.size())).toDouble().round(); def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; def epImdbId = episodeInfo.external_ids.imdb_id; (allOf{ny}{s00e00}{t}{OMDbEpisodeInfo.Genre}{'c'{avg}}{'r'{OMDbEpisodeInfo.imdbRating}}{vf}{vc}{ac}{epImdbId}).join(' ')}"
please modify the code presented above. also I would love to have the year be taken from the omdb air date.

Re: please is there any way to use TheMovieDb for series?

Posted: 01 Dec 2018, 11:43
by rednoah
1.
This is weird:

Code: Select all

\u0022tv/${id}\u0022

2.
It also seems net.filebot.WebServices.TheTVDB has been find-and-replaced with net.filebot.WebServices.TheMovieDB which is completely incompatible. net.filebot.WebServices.TheMovieDB_TV on the other hand might implement the EpisodeListProvider interface just as net.filebot.WebServices.TheTVDB does. It's complicated, and really more about writing FileBot code, than writing format code.

:idea: But since this is more and more about internal APIs I must stress that internal APIs are subject to change, and writing format code highly dependant on internal APIs is strongly discouraged, since it's not documented and will likely break with future releases.

:idea: It seems as if you're testing this on the command-line, without making sure it's working at all in the GUI Format Editor first. This approach will result in misery. Using the GUI Format Editor for prototyping first is highly recommended.

:idea: You're probably dealing with multiple issues at the same time, format fundamentally not working, but also command-line messing up the format value, so it's best to prototype in the GUI Format Editor so you can make sure that format itself is working, and then you can use the multi-line literal to pass it in as is. Step by Step.

Re: please is there any way to use TheMovieDb for series?

Posted: 01 Dec 2018, 12:16
by rednoah
Let's find out how to figure things out step by step.

Step 1:

Code: Select all

{
	def season = (any{special ? 0 : s} {s})
}

Code: Select all

1
Step 2:

Code: Select all

{
	def season = (any{special ? 0 : s} {s})
	def episode = (any{special ? special : e} {e})
}

Code: Select all

1
Step 3:

Code: Select all

{
	def season = (any{special ? 0 : s} {s})
	def episode = (any{special ? special : e} {e})
	def eAddOns = ['append_to_response':'external_ids']
	def sAddOns = ['append_to_response':'external_ids,content_ratings']
	def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US)
}

Code: Select all

{air_date=2016-09-06, crew=[Ljava.lang.Object;@7c167ad1, episode_number=1, guest_stars=[Ljava.lang.Object;@41577f51, name=Seed Money, overview=When Miami tech visionary Izzy Morales fails to attract funding for her new cryptocurrency GenCoin, financier Nick Talman funnels dirty money from his embezzling father. Meanwhile, gangster Ronald Dacey finds his money is missing, while cynical FBI agent Phil Rask hunts for Nick’s father., id=1216012, production_code=null, season_number=1, still_path=/tT50TbFpYqwsNqJX1ZmjG5eprCm.jpg, vote_average=5.5, vote_count=2, external_ids={imdb_id=tt5653618, freebase_mid=null, freebase_id=null, tvdb_id=5645387, tvrage_id=null}}
Step 4:

Code: Select all

{
	def season = (any{special ? 0 : s} {s})
	def episode = (any{special ? special : e} {e})
	def eAddOns = ['append_to_response':'external_ids']
	def sAddOns = ['append_to_response':'external_ids,content_ratings']
	def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US)
	def epRating = episodeInfo.vote_average
	def seriesInfo = net.filebot.WebServices.TheMovieDB.request("${id}", sAddOns, Locale.US)
}

Code: Select all

Expression yields empty value: Resource is empty: {} => https://api.themoviedb.org/3/66310?append_to_response=external_ids%2Ccontent_ratings&language=en-US
:arrow: We see that the last line causes an error. Maybe it generally doesn't work. Maybe it only specifically doesn't work for this particular show. If the code is wrong, we have to change the code. If it just doesn't work for some shows, then we need to catch errors, and use default values instead. This usually accomplished via any{...}{...}. Kinda depends on what you guys want the code to do.

Re: please is there any way to use TheMovieDb for series?

Posted: 01 Dec 2018, 18:53
by kim

Code: Select all

{
def season = (any{special ? 0 : s} {s}); 
def episode = (any{special ? special : e} {e}); 
def eAddOns = ['append_to_response':'external_ids']; 
def sAddOns = ['append_to_response':'external_ids,content_ratings']; 
def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); 
def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); 
def epRating = episodeInfo.vote_average; 
def epImdbId = episodeInfo.external_ids.imdb_id; 
def sImdbId = seriesInfo.external_ids.imdb_id; 
def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; 
def OMDbSeriesInfo = (sImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':sImdbId]) : null; 
def epOMDbVotes = any{OMDbEpisodeInfo.imdbVotes as int}{null}; 
def sOMDbVotes = any{OMDbSeriesInfo.imdbVotes.replaceAll('\\D') as int}{null}; 
def scleanNum = seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('\\D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}; 
int savg = (scleanNum.sum().div(scleanNum.size())).toDouble().round(); 
def eOMDbYear = OMDbEpisodeInfo.Released.match(/(?:19|20)\d{2}/); 
def sOMDbYear = OMDbSeriesInfo.Released.match(/(?:19|20)\d{2}/); 
(allOf{ny}{s00e00}{t}{OMDbEpisodeInfo.Genre.split(',')}{'c'+any{savg}{'NR'}}{'r'+any{OMDbEpisodeInfo.imdbRating.replaceAll(/N\/A/)}{epRating.round(1)}{' '}}{vf}{vc}{ac}{any{epImdbId}{sImdbId}}).join(' ')
}
sample
Firefly (2002) S01E01 The Train Job [Adventure, Drama, Sci-Fi] c14 r8.5 tt0579539
I think it's bad. but use eOMDbYear and/or sOMDbYear how you want.
the year be taken from the omdb air date.
btw:
\u0022
= "
I was thinking it was better to use in the 1 line CLI, with the escaping stuff ?

Re: please is there any way to use TheMovieDb for series?

Posted: 02 Dec 2018, 03:26
by rednoah
Just use PowerShell so you can use @''@ multi-line literal so you don't have to worry about escaping at all:

e.g.

Code: Select all

--format @'
{n}
 - 
{s00e00}
 - 
{t}
'@

Re: please is there any way to use TheMovieDb for series?

Posted: 02 Dec 2018, 12:48
by cafevincent
seems perfect. I even got the year wrapped in brackets. thank you so much for the both of you!

Code: Select all

-rename
--db
TheMovieDB::TV
--format
"{def season = (any{special ? 0 : s} {s}); def episode = (any{special ? special : e} {e}); def eAddOns = ['append_to_response':'external_ids']; def sAddOns = ['append_to_response':'external_ids,content_ratings']; def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); def epRating = episodeInfo.vote_average; def epImdbId = episodeInfo.external_ids.imdb_id; def sImdbId = seriesInfo.external_ids.imdb_id; def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; def OMDbSeriesInfo = (sImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':sImdbId]) : null; def epOMDbVotes = any{OMDbEpisodeInfo.imdbVotes as int}{null}; def sOMDbVotes = any{OMDbSeriesInfo.imdbVotes.replaceAll('\\D') as int}{null}; def scleanNum = seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('\\D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}; int savg = (scleanNum.sum().div(scleanNum.size())).toDouble().round(); def eOMDbYear = OMDbEpisodeInfo.Released.match(/(?:19|20)\d{2}/); def sOMDbYear = OMDbSeriesInfo.Released.match(/(?:19|20)\d{2}/); (allOf{n}{any{'('+eOMDbYear+')'}{'('+sOMDbYear+')'}}{s00e00}{t}{OMDbEpisodeInfo.Genre.split(',')}{'c'+any{savg}{'NR'}}{'r'+any{OMDbEpisodeInfo.imdbRating.replaceAll(/N\/A/)}{epRating.round(1)}{' '}}{vf}{vc}{ac}{any{epImdbId}{sImdbId}}).join(' ')}"

Re: please is there any way to use TheMovieDb for series?

Posted: 02 Dec 2018, 14:52
by cafevincent
I just discovered that some shows still get a blank filename, for example the show called "gary and his demons (2018)". this show only has the single alphabetical "tv-ma" for certification, I suspect this is the reason for the failure.

instead of nullifying in a situation like this, maybe it would be ideal to display the only (non-numeral) rating as-is? I have the retype script that can change those to whatever is needed. I tried doing this like

Code: Select all

{'c'+any{savg}{certification}{'NR'}}
but it's no good, filename still blank. I should find another one that doesn't work and look for connections just in case.

Re: please is there any way to use TheMovieDb for series?

Posted: 02 Dec 2018, 17:23
by kim

Code: Select all

certification
is broken (undefined) on TheMovieDB::TV

Code: Select all

{
def season = (any{special ? 0 : s} {s}); 
def episode = (any{special ? special : e} {e}); 
def eAddOns = ['append_to_response':'external_ids']; 
def sAddOns = ['append_to_response':'external_ids,content_ratings']; 
def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); 
def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); 
def epRating = episodeInfo.vote_average; 
def epImdbId = episodeInfo.external_ids.imdb_id; 
def sImdbId = seriesInfo.external_ids.imdb_id; 
def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; 
def OMDbSeriesInfo = (sImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':sImdbId]) : null; 
def epOMDbVotes = any{OMDbEpisodeInfo.imdbVotes as int}{null}; 
def sOMDbVotes = any{OMDbSeriesInfo.imdbVotes.replaceAll('\\D') as int}{null}; 
def scleanNum = any{seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('\\D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}}{null}; 
int savg = any{(scleanNum.sum().div(scleanNum.size())).toDouble().round()}{null}; 
def eOMDbYear = any{OMDbEpisodeInfo.Released.match(/(?:19|20)\d{2}/)}{null}; 
def sOMDbYear = any{OMDbSeriesInfo.Released.match(/(?:19|20)\d{2}/)}{null}; 
(allOf{n}{'('+any{eOMDbYear}{sOMDbYear}+')'}{s00e00}{t}{OMDbEpisodeInfo.Genre.split(',')}{'c'+any{savg}{seriesInfo.content_ratings.results.rating[0]}{'NR'}}{'r'+any{OMDbEpisodeInfo.imdbRating.replaceAll(/N\/A/)}{epRating.round(1).toString().replaceAll(/0.0/)}{rating}{' '}}{vf}{vc}{ac}{any{epImdbId}{sImdbId}}).join(' ')
}
Gary and His Demons (2018) S01E01 Still The One cTV-MA r9.0 tt8421152

better... replaced eOMDbYear/sOMDbYear with epYear/y

Code: Select all

{
def season = (any{special ? 0 : s} {s}); 
def episode = (any{special ? special : e} {e}); 
def eAddOns = ['append_to_response':'external_ids']; 
def sAddOns = ['append_to_response':'external_ids,content_ratings']; 
def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); 
def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); 
def epRating = episodeInfo.vote_average; 
def epImdbId = episodeInfo.external_ids.imdb_id; 
def sImdbId = seriesInfo.external_ids.imdb_id; 
def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; 
def OMDbSeriesInfo = (sImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':sImdbId]) : null; 
def epOMDbVotes = any{OMDbEpisodeInfo.imdbVotes as int}{null}; 
def sOMDbVotes = any{OMDbSeriesInfo.imdbVotes.replaceAll('\\D') as int}{null}; 
def scleanNum = any{seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('\\D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}}{null}; 
def savg = any{(scleanNum.sum().div(scleanNum.size())).toDouble().round() as int }{seriesInfo.content_ratings.results.rating[0]}{null}; 
def epYear = any{episodeInfo.air_date.match(/(?:19|20)\d{2}/)}{null}; 
(allOf{n}{'('+any{epYear}{y}+')'}{s00e00}{t}{OMDbEpisodeInfo.Genre.split(',')}{'c'+any{savg}{}{'NR'}}{'r'+any{OMDbEpisodeInfo.imdbRating.replaceAll(/N\/A/)}{epRating.round(1).toString().replaceAll(/0.0/)}{rating}{' '}}{vf}{vc}{ac}{any{epImdbId}{sImdbId}}).join(' ')
}

Re: please is there any way to use TheMovieDb for series?

Posted: 03 Dec 2018, 16:57
by cafevincent
in the middle of rewriting all south park episodes I got 3 episodes in a row (s18e07-s018e09) that were renamed differently:

-there was no genres, only the brackets
-they all had different rating than imdb
-they all had the series imdb id

I was guessing there was a momentary lapse of connection to omdb, but I'm getting massive amounts of files named like this for lesser known shows. this also started happening to "gary and his demons" after your last adjustment. I will investigate more and report back another day.

Re: please is there any way to use TheMovieDb for series?

Posted: 02 Jan 2019, 06:00
by cafevincent
I am getting an error "Unexpected token: A" even though there definitely is no runaway A characters.

Code: Select all

-rename
--db
TheMovieDB::TV
--format
"{def season = (any{special ? 0 : s} {s}); def episode = (any{special ? special : e} {e}); def eAddOns = ['append_to_response':'external_ids']; def sAddOns = ['append_to_response':'external_ids,content_ratings']; def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); def epRating = episodeInfo.vote_average; def epImdbId = episodeInfo.external_ids.imdb_id; def sImdbId = seriesInfo.external_ids.imdb_id; def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; def OMDbSeriesInfo = (sImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':sImdbId]) : null; def epOMDbVotes = any{OMDbEpisodeInfo.imdbVotes as int}{null}; def sOMDbVotes = any{OMDbSeriesInfo.imdbVotes.replaceAll('D') as int}{null}; def scleanNum = any{seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}}{null}; def savg = any{(scleanNum.sum().div(scleanNum.size())).toDouble().round() as int }{seriesInfo.content_ratings.results.rating[0]}{null}; def epYear = any{episodeInfo.air_date.match(/(?:19|20)d{2}/)}{null}; (allOf{n}{'('+{epYear}+')'}{s00e00}{t}{'['+{OMDbEpisodeInfo.Genre}+']'}{'c'+any{savg}{}{'NR'}}{'r'+any{OMDbEpisodeInfo.imdbRating.replaceAll(/N/A/)}{epRating.round(1).toString().replaceAll(/0.0/)}{rating}{' '}}{vf}{vc}{ac}{epImdbId}).join(' ')}"

Re: please is there any way to use TheMovieDb for series?

Posted: 02 Jan 2019, 06:52
by rednoah
Best to use the Format Editor GUI to debug custom formats.

If the format works fine in the GUI, then it's a command line issues, things getting interpreted by your shell in unexpected ways. In this case, using PowerShell and multi-line literals @""@ should do the trick.

Re: please is there any way to use TheMovieDb for series?

Posted: 02 Jan 2019, 22:03
by kim
how do you remove/replace e.g. this ?
N/A
does the year work ?

also is this the same ?

Code: Select all

replaceAll('\\D')
and

Code: Select all

replaceAll('D')
again, you change code without testing in GUI ?

btw it's better to use

Code: Select all

OMDbSeriesInfo.Genre
then

Code: Select all

OMDbEpisodeInfo.Genre
because OMDb is so unreliable, mostly with new shows

Re: please is there any way to use TheMovieDb for series?

Posted: 03 Mar 2019, 19:20
by cafevincent
I figured out the '/N/A/' to '/N\/A/' thing. now the only problem seems to be that currently epYear produces an empty value

Code: Select all

{def season = (any{special ? 0 : s} {s}); def episode = (any{special ? special : e} {e}); def eAddOns = ['append_to_response':'external_ids']; def sAddOns = ['append_to_response':'external_ids,content_ratings']; def episodeInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}/season/${season}/episode/${episode}", eAddOns, Locale.US); def seriesInfo = net.filebot.WebServices.TheMovieDB.request("tv/${id}", sAddOns, Locale.US); def epRating = episodeInfo.vote_average; def epImdbId = episodeInfo.external_ids.imdb_id; def sImdbId = seriesInfo.external_ids.imdb_id; def OMDbEpisodeInfo = (epImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':epImdbId]) : null; def OMDbSeriesInfo = (sImdbId != null) ? net.filebot.WebServices.OMDb.request(['i':sImdbId]) : null; def epOMDbVotes = any{OMDbEpisodeInfo.imdbVotes as int}{null}; def sOMDbVotes = any{OMDbSeriesInfo.imdbVotes.replaceAll('D') as int}{null}; def scleanNum = any{seriesInfo.content_ratings.results*.findResults{key, value -> value.replaceAll('D')}.flatten().findAll{it}*.toInteger().findAll{it < 22}}{null}; def savg = any{(scleanNum.sum().div(scleanNum.size())).toDouble().round() as int }{seriesInfo.content_ratings.results.rating[0]}{null}; def epYear = any{episodeInfo.air_date.match(/(?:19|20)d{2}/)}{null}; (allOf{n}{'('+{epYear}+')'}{s00e00}{t}{'['+{OMDbEpisodeInfo.Genre}+']'}{'c'+any{savg}{}{'NR'}}{'r'+any{OMDbEpisodeInfo.imdbRating.replaceAll(/N\/A/)}{epRating.round(1).toString().replaceAll(/0.0/)}{rating}{' '}}{vf}{vc}{ac}{epImdbId}).join(' ')}

Re: please is there any way to use TheMovieDb for series?

Posted: 07 Mar 2019, 00:44
by kim

Code: Select all

def epYear = any{episodeInfo.air_date.match(/(?:19|20)d{2}/)}{null};

Code: Select all

{episodeInfo.air_date.match(/(?:19|20)d{2}/)}
= ?

Code: Select all

{episodeInfo.air_date.match(/(?:19|20)/)}
= ?

Code: Select all

{episodeInfo.air_date}
= ?

try and you find problem ;)

btw: Gui will only show output of last line, so best to test with is remove the "(allOf..." line

Re: please is there any way to use TheMovieDb for series?

Posted: 24 Mar 2019, 10:22
by cafevincent
I'm trying this in the GUI with the default Firefly example selected.

Code: Select all

{episodeInfo.air_date.match(/(?:19|20)d{2}/)}

Code: Select all

Expression yields empty value: Patter not found: 2018-04-13
It looks like this code is trying to fetch a 4-digit value starting with 19 or 20 but somehow fails to match the 2018.

Code: Select all

{episodeInfo.air_date.match(/(?:19|20)/)}

Code: Select all

20
It finds the 19/20 bit just fine, there must be something wrong with the d{2} bit of the code. Not sure how that works but it looks like d stands for digits and {2} should allow for any two numbers. I must be getting this wrong.

Code: Select all

{episodeInfo.air_date}

Code: Select all

2018-04-13
This is not the original air date for Firefly S01E01, there must be something horribly wrong.

Re: please is there any way to use TheMovieDb for series?

Posted: 24 Mar 2019, 10:40
by rednoah
Best to read up on how regular expressions work for a bit first.

\d means single digit, d just means a single d.

In this case, you could just match \d+ to match the first number sequence.