Skip to content

Instantly share code, notes, and snippets.

@AdelMmdi
Last active September 13, 2024 22:09
Show Gist options
  • Select an option

  • Save AdelMmdi/0965850085d83d8fe735ec5b810ca75d to your computer and use it in GitHub Desktop.

Select an option

Save AdelMmdi/0965850085d83d8fe735ec5b810ca75d to your computer and use it in GitHub Desktop.
Cover or Posters MOVIE help to select article with second watch and memory refresh
import movieposters
import requests
import glob
from mutagen.mp4 import MP4, MP4Cover
def movie_to_cover(title, fname):
m_title = title[:-4]
print(m_title)
pic_url = movieposters.get_poster(m_title)
print(pic_url)
pic = '%s.jpg' % title
with open(pic, 'wb') as handle:
response = requests.get(pic_url, stream=True)
if not response.ok:
print(response)
for block in response.iter_content(1024):
if not block:
break
handle.write(block)
pic = '%s.jpg' % title
if 'mp4' in fname:
MP4file = MP4(fname)
with open(pic, 'rb') as f:
albumart = MP4Cover(f.read(), imageformat='MP4Cover.FORMAT_JPEG')
MP4file.tags['covr'] = [bytes(albumart)]
MP4file.save(fname)
movie_to_cover(x, title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment