please is there any way to use TheMovieDb for series?

Support for Windows 10 users and the Microsoft Store package
cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 11 Nov 2018, 12:56

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(' ')}"

kim
Power User
Posts: 676
Joined: 15 May 2014, 16:17

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

Post by kim » 12 Nov 2018, 19:13

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 ?

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 12 Nov 2018, 20:26

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.

kim
Power User
Posts: 676
Joined: 15 May 2014, 16:17

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

Post by kim » 17 Nov 2018, 17:34

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(); 
}

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 18 Nov 2018, 16:55

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.

kim
Power User
Posts: 676
Joined: 15 May 2014, 16:17

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

Post by kim » 18 Nov 2018, 17:09

where is the { ?

Code: Select all

--format
"def season

Code: Select all

--format
"{def season

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 01 Dec 2018, 11:30

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.

User avatar
rednoah
The Source
Posts: 15341
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post by rednoah » 01 Dec 2018, 11:43

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.
:idea: Please read the FAQ and How to Request Help.

User avatar
rednoah
The Source
Posts: 15341
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post by rednoah » 01 Dec 2018, 12:16

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.
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 676
Joined: 15 May 2014, 16:17

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

Post by kim » 01 Dec 2018, 18:53

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 ?

User avatar
rednoah
The Source
Posts: 15341
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post by rednoah » 02 Dec 2018, 03:26

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}
'@
:idea: Please read the FAQ and How to Request Help.

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 02 Dec 2018, 12:48

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(' ')}"

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 02 Dec 2018, 14:52

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.

kim
Power User
Posts: 676
Joined: 15 May 2014, 16:17

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

Post by kim » 02 Dec 2018, 17:23

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(' ')
}

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 03 Dec 2018, 16:57

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.

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 02 Jan 2019, 06:00

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(' ')}"

User avatar
rednoah
The Source
Posts: 15341
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post by rednoah » 02 Jan 2019, 06:52

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.
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 676
Joined: 15 May 2014, 16:17

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

Post by kim » 02 Jan 2019, 22:03

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

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » 03 Mar 2019, 19:20

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(' ')}

kim
Power User
Posts: 676
Joined: 15 May 2014, 16:17

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

Post by kim » 07 Mar 2019, 00:44

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

cafevincent
Posts: 54
Joined: 22 Jun 2017, 10:08

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

Post by cafevincent » Yesterday, 10:22

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.

User avatar
rednoah
The Source
Posts: 15341
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

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

Post by rednoah » Yesterday, 10:40

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.
:idea: Please read the FAQ and How to Request Help.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests