Repository: pymedusa/Medusa

Issue:
Unable to add `1883` from TMDB
**Describe the bug**
Want to add the show `1883` to my list from TMDB where it is available but get no results.  https://www.themoviedb.org/tv/118357-1883
![image](https://user-images.githubusercontent.com/4103090/147637425-c4d102a4-6c33-4fad-89b6-40a9a64b548a.png)

Not sure it this is releted to: https://github.com/pymedusa/Medusa/issues/10195

<html><body>
<!--StartFragment--><h1 class="header">Medusa Configuration</h1> <div data-v-84755812="" id="config-content">

Medusa Info: | Branch:                 master                  Commit:                 1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38                  Version:                 0.5.22                  Database:                 44.18
-- | --
Python Version: | 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
SSL Version: | OpenSSL 1.1.1l  24 Aug 2021
OS: | Windows-10-10.0.17763-SP0
Locale: | nl_NL.cp1252
Timezone: | W. Europe Standard Time

</div><!--EndFragment-->
</body>
</html>

**Debug logs (at least 50 lines):**
General > Advanced Settings > Enable debug
<details>

```
2021-12-29 08:24:41 ERROR    APIv2-Thread_12 :: [1405fbb] Internal Error searching for show. term(s): ['1883', '(1883)'] indexer: tmdb error: 'dict' object has no attribute 'append'
Traceback (most recent call last):
  File "C:\GitHub\Medusa\medusa\server\api\v2\internal.py", line 246, in resource_search_indexers_for_show_name
    indexer_results = indexer_api[search_term]
  File "C:\GitHub\Medusa\medusa\indexers\base.py", line 403, in __getitem__
    selected_series = self._get_series(key)
  File "C:\GitHub\Medusa\medusa\indexers\base.py", line 157, in _get_series
    all_series = self.search(series)
  File "C:\GitHub\Medusa\medusa\indexers\tmdb\api.py", line 205, in search
    mapped_results.append(show_by_id['series'])
AttributeError: 'dict' object has no attribute 'append
'```
</details>



Discussion:
Use one(or all) of the other indexers, this show is apparently not to be found via the API on TMDB.
The TMDB api is still WIP (Work In Progress).
> The TMDB api is still WIP (Work In Progress).

Is that from the side of Medusa or TMDB?

Since I'm able to find it using a API call
https://api.themoviedb.org/3/search/tv?api_key=APIKEY&language=en-US&page=1&query=1883&include_adult=false
On the Medusa site it is still WIP.
I'll check it out. Maybe it's assuming it should search by Id.
Think is is something like that, it does work for tvdb and tvmaze.
Also tried searching with quotes and stuff around it but couldn't get it to play ball.
Might try to add it through tvmaze and then edit the DB to point it it tmdb and do a full update after that.
And when you try searching by tmdb Id?
Searching it with 118357 does work indeed.

Resolving patch:
diff --git a/medusa/indexers/tmdb/api.py b/medusa/indexers/tmdb/api.py
--- a/medusa/indexers/tmdb/api.py
+++ b/medusa/indexers/tmdb/api.py
@@ -199,6 +199,8 @@ def search(self, series):
         mapped_results = []
         if results:
             mapped_results = self._map_results(results, self.series_map, '|')
+            if not isinstance(mapped_results, list):
+                mapped_results = [mapped_results]
 
         # The search by id result, is already mapped. We can just add it to the array with results.
         if show_by_id:


Test patch: