tmcknight / Movie-and-TV-Show-Search-Alfred-Workflow

An Alfred workflow to search for a movie (or TV show) and get a few ratings
MIT License
95 stars 7 forks source link

Adding Year #15

Closed MohammadOtb closed 3 years ago

MohammadOtb commented 3 years ago

Hi,

I would like to add a website with providing title + year on the search. How could I do that?

tmcknight commented 3 years ago

Hi @MohammadOtb. There is no official method for adding custom websites to this workflow. However, you can check out the code in media.py under show_item_info. You'd add something like this:

search_url = 'https://mycoolmoviesite.com/moviesearch?title=' + title
all_search_sites.append(search_url)
wf.add_item(title='Custom Site Name',
              subtitle='Search Custom Site for \'' + item[title_key] + '\'',
              icon='img/imdb.png',
              valid=True,
              arg=search_url)

If you tweak that code to the website you wanted and added it around line 158, it should get you what you're after. Good luck!

MohammadOtb commented 3 years ago

Yea I added many websites, but I need to specify the year in the search. So no method to extract the year from (get_omdb_info)? I need just the correct command for that (sad face!).

tmcknight commented 3 years ago

Try this to get the year:

if item[release_date_key]:
        year = item[release_date_key][:4]