spacepaste

  1.  
  2. # Shawn Quintal email @ snowcatman@gmail.com
  3. # beginning of file example.py getting ready for post processing media files.
  4. import os # imports the os module
  5. import sys # import the sys module
  6. import time # import the time module
  7. from imdb import IMDb # imports IMDB function from module imdb Note could not find the module in python software
  8. # folder. I need to clerify my understanding of modules and functions
  9. # I am woundering if I can have a chat with anyone about imdbpy? I have created a database from imdb.com dataset
  10. # files and I am accessing it. I am attempting to learn about the way I access it. So I can get information and
  11. # proccess it. It, seem the mixed syntax of sql imdbpy and python, is troupling me. In a way that I am not
  12. # understanding. An example is how to get the year out of a movie. Here is what i have so far. with a
  13. # instructional link first then what I have so far.
  14. # Link to instruction web site.
  15. # https://imdbpy.readthedocs.io/en/latest/usage/s3.html
  16. # https://imdbpy.readthedocs.io/en/latest/index.html
  17. # https://imdbpy.readthedocs.io/en/latest/usage/ptdf.html
  18. # https://imdbpy.readthedocs.io/en/latest/usage/data-interface.html
  19. # begin user input prompt
  20. os.system('cls'), # clears windows cmd.exe screen
  21. print()
  22. print(" Beginning example.py")
  23. time.sleep(1)
  24. os.system('cls'), # clears windows cmd.exe screen
  25. My_path = "C:\python3_imdb_learning_area\media_temp_list.txt"
  26. if os.path.isfile(My_path):
  27. # print("True")
  28. print()
  29. print(" cleaning file -- media_temp_list.txt")
  30. f = open('media_temp_list.txt', 'w')
  31. f.write('')
  32. f.close()
  33. print(" ready...")
  34. else:
  35. # print("False")
  36. print(" will create or append to -- media_temp_list.txt")
  37. time.sleep(2)
  38. os.system('cls'), # clears windows cmd.exe screen
  39. MyMovieSearch = input('\n What is the movie title you want to search for? : ')
  40. # the above line: create a string from users input in a tuple object
  41. # print(MyMovieSearch) # print string from tuple
  42. # I would like to get the unknown movie - title, startYear, runtimeMinutes and movie rating. For now.
  43. # If it does not have the info, return null or none and/or leave a "'_'" for the missing info.
  44. # I have been making attempts to understand how to get and use keys to get the information.
  45. print(); print(" ---------------------Your Movie----->(", MyMovieSearch, ")<--Seeking")
  46. print("working...")
  47. print()
  48. # the above two lines just help confirm to the user there print out of there movie. by printing the tuple object
  49. # end user input prompt
  50. # begin movie search
  51. ia = IMDb('s3', 'sqlite:///c:\\python3_imdb_learning_area\\imdb\\imdb.db')
  52. # the above line: uses the IMDB module, to make a tuple of strings using the s3 module as argument one,
  53. # and use sqlite module to access database for read/write as argument two.
  54. results = ia.search_movie(MyMovieSearch)
  55. # The above line: creates a string or a list of strings from the ia object as another tuple object.
  56. # The above line to be explained further. i.e "ia.search_movie".
  57. # Now I have seen something like this before, and want to know more about how to use it to get my info.
  58. # And what other options I my have.
  59. for result in results:
  60. #for something in something???
  61. print(result.movieID)
  62. # expected more of the results: title, year, rating, and any other info associated with the title.
  63. # I have been doing a mix of other functions to get the startYear but no success.
  64. results1 = ia.get_movie(result.movieID)
  65. orig_stdout = sys.stdout
  66. f = open('media_temp_list.txt', 'a')
  67. sys.stdout = f
  68. print()
  69. print(results1)
  70. print("(", results1.get('year'), ")<-->(", results1.get('startYear'), ") <------ year vs. startYear")
  71. print()
  72. print("genres-------------->", results1.get('genres'))
  73. print("akas---------------->", results1.get('akas'))
  74. print("kind---------------->", results1.get('kind'))
  75. print("title--------------->", results1.get('title'))
  76. print("original title------>", results1.get('original title'))
  77. print("runtimes------------>", results1.get('runtimes'))
  78. print("director------------>", results1.get('director'))
  79. print("writer-------------->", results1.get('writer'))
  80. print("ordering------------>", results1.get('ordering'))
  81. print("rating-------------->", results1.get('rating'))
  82. print()
  83. print("imdb keys----------->", results1.infoset2keys)
  84. print()
  85. print(results1.current_info)
  86. print()
  87. print("---------------new line-----------------")
  88. print()
  89. sys.stdout = orig_stdout
  90. f.close()
  91. # print("Finnished -- file -- media_temp_list.txt -- is ready -- in the loop")
  92. # print("test")
  93. # print("Finnished -- file -- media_temp_list.txt -- is ready -- out of loop")
  94. # end movie search
  95. os.system('cls'), # clears windows cmd.exe screen
  96. print()
  97. print(" end of module example.py")
  98. time.sleep(1)
  99. os.system('cls')
  100. # begin copy/paste from command prompt
  101. # What is the movie title you want to search for? : supergirl
  102. #
  103. # ---------------------Your Movie----->( supergirl )<--Seeking
  104. # working...
  105. #
  106. # 8814476
  107. # 7981448
  108. # 6837238
  109. # 6537530
  110. # 5912646
  111. # 4872854
  112. # 4397094
  113. # 4016454
  114. # Traceback (most recent call last):
  115. # File "example.py", line 82, in <module>
  116. # print("akas---------------->", results1.get('akas'))
  117. # File "C:\Program Files (x86)\Python37-32\lib\encodings\cp1252.py", line 19, in encode
  118. # return codecs.charmap_encode(input,self.errors,encoding_table)[0]
  119. # UnicodeEncodeError: 'charmap' codec can't encode characters in position 44-54: character maps to <undefined>
  120. #
  121. # c:\python3_imdb_learning_area>
  122. # end copy/paste
  123. # ========================================================
  124. # begin copy/paste media_temp_list.txt
  125. # Supergirl
  126. # ( None )<-->( None ) <------ year vs. startYear
  127. #
  128. # genres--------------> ['action']
  129. # akas----------------> None
  130. # kind----------------> movie
  131. # title---------------> Supergirl
  132. # original title------> Supergirl
  133. # runtimes------------> None
  134. # director------------> None
  135. # writer--------------> [<Person id:3349927[s3] name:_Oren Uziel_>]
  136. # ordering------------> 1
  137. # rating--------------> None
  138. #
  139. # imdb keys-----------> {'main': ['genres', 'kind', 'title', 'original title', 'adult', 'writer', 'job', 'ordering', 'category', 'nconst']}
  140. #
  141. # ['main', 'plot']
  142. #
  143. # ---------------new line-----------------
  144. #
  145. #
  146. # SuperGirl
  147. # ( 2018 )<-->( None ) <------ year vs. startYear
  148. #
  149. # genres--------------> ['drama', 'short']
  150. # akas----------------> [{'region': 'IT', 'ordering': 1, 'title': 'SuperGirl'}, {'ordering': 2, 'types': ['original'], 'title': 'SuperGirl', 'original':
  151. # True}, {'ordering': 3, 'types': ['working'], 'title': 'ProjectX'}]
  152. # kind----------------> short
  153. # title---------------> SuperGirl
  154. # original title------> SuperGirl
  155. # runtimes------------> [3]
  156. # director------------> [<Person id:157178[s3] name:_Max Chicco_>]
  157. # writer--------------> [<Person id:157178[s3] name:_Max Chicco_>, <Person id:4171284[s3] name:_Simona Rapello_>]
  158. # ordering------------> 1
  159. # rating--------------> None
  160. #
  161. # imdb keys-----------> {'main': ['genres', 'kind', 'title', 'original title', 'adult', 'runtimes', 'year', 'director', 'writer', 'ordering',
  162. # 'category', 'characters', 'nconst', 'akas']}
  163. #
  164. # ['main', 'plot']
  165. #
  166. # ---------------new line-----------------
  167. #
  168. #
  169. # Supergirl
  170. # ( 2016 )<-->( None ) <------ year vs. startYear
  171. #
  172. # genres--------------> ['comedy']
  173. # akas----------------> [{'region': 'US', 'ordering': 1, 'title': 'Supergirl'}]
  174. # kind----------------> episode
  175. # title---------------> Supergirl
  176. # original title------> Supergirl
  177. # runtimes------------> None
  178. # director------------> None
  179. # writer--------------> None
  180. # ordering------------> 1
  181. # rating--------------> 8.4
  182. #
  183. # imdb keys-----------> {'main': ['genres', 'kind', 'title', 'original title', 'adult', 'year', 'directors', 'ordering', 'category', 'characters',
  184. # 'nconst', 'rating', 'votes', 'akas']}
  185. #
  186. # ['main', 'plot']
  187. #
  188. # ---------------new line-----------------
  189. #
  190. #
  191. # Supergirl
  192. # ( 2011 )<-->( None ) <------ year vs. startYear
  193. #
  194. # genres--------------> ['music', 'short']
  195. # akas----------------> [{'region': 'US', 'ordering': 1, 'title': 'Supergirl'}]
  196. # kind----------------> video
  197. # title---------------> Supergirl
  198. # original title------> Supergirl
  199. # runtimes------------> [4]
  200. # director------------> [<Person id:6489846[s3] name:_Kevin Wendell Jones_>]
  201. # writer--------------> [<Person id:6489846[s3] name:_Kevin Wendell Jones_>]
  202. # ordering------------> 1
  203. # rating--------------> None
  204. #
  205. # imdb keys-----------> {'main': ['genres', 'kind', 'title', 'original title', 'adult', 'runtimes', 'year', 'director', 'writer', 'ordering',
  206. # 'category', 'characters', 'nconst', 'akas']}
  207. #
  208. # ['main', 'plot']
  209. #
  210. # ---------------new line-----------------
  211. #
  212. #
  213. # Supergirl
  214. # ( 2016 )<-->( None ) <------ year vs. startYear
  215. #
  216. # genres--------------> ['short']
  217. # akas----------------> None
  218. # kind----------------> short
  219. # title---------------> Supergirl
  220. # original title------> Supergirl
  221. # runtimes------------> None
  222. # director------------> [<Person id:4012098[s3] name:_Olivier Mathieu_>]
  223. # writer--------------> [<Person id:4012098[s3] name:_Olivier Mathieu_>]
  224. # ordering------------> 1
  225. # rating--------------> None
  226. #
  227. # imdb keys-----------> {'main': ['genres', 'kind', 'title', 'original title', 'adult', 'year', 'director', 'writer', 'ordering', 'category',
  228. # 'characters', 'nconst']}
  229. #
  230. # ['main', 'plot']
  231. #
  232. # ---------------new line-----------------
  233. #
  234. #
  235. # Supergirl
  236. # ( 2013 )<-->( None ) <------ year vs. startYear
  237. #
  238. # genres--------------> ['drama', 'mystery', 'short']
  239. # akas----------------> [{'region': 'US', 'ordering': 1, 'title': 'Supergirl'}]
  240. # kind----------------> short
  241. # title---------------> Supergirl
  242. # original title------> Supergirl
  243. # runtimes------------> [5]
  244. # director------------> [<Person id:5225627[s3] name:_Aleksandar Adzic_>]
  245. # writer--------------> [<Person id:5225627[s3] name:_Aleksandar Adzic_>, <Person id:4594601[s3] name:_Christian Kemabia_>]
  246. # ordering------------> 1
  247. # rating--------------> None
  248. #
  249. # imdb keys-----------> {'main': ['genres', 'kind', 'title', 'original title', 'adult', 'runtimes', 'year', 'director', 'writer', 'ordering', #
  250. 'category', 'characters', 'nconst', 'akas']}
  251. #
  252. # ['main', 'plot']
  253. #
  254. # ---------------new line-----------------
  255. #
  256. #
  257. # Supergirl
  258. # ( 2016 )<-->( None ) <------ year vs. startYear
  259. #
  260. # genres--------------> ['documentary']
  261. # akas----------------> [{'region': 'CA', 'ordering': 1, 'title': 'Supergirl'}]
  262. # kind----------------> movie
  263. # title---------------> Supergirl
  264. # original title------> Supergirl
  265. # runtimes------------> [80]
  266. # director------------> [<Person id:3492557[s3] name:_Jessie Auritt_>]
  267. # writer--------------> None
  268. # ordering------------> 1
  269. # rating--------------> 6.8
  270. #
  271. # imdb keys-----------> {'main': ['genres', 'kind', 'title', 'original title', 'adult', 'runtimes', 'year', 'director', 'ordering', 'category', #
  272. 'nconst', 'rating', 'votes', 'akas']}
  273. #
  274. # ['main', 'plot']
  275. #
  276. # ---------------new line-----------------
  277. #
  278. #
  279. # Supergirl
  280. # ( 2015 )<-->( None ) <------ year vs. startYear
  281. #
  282. # genres--------------> ['action', 'adventure', 'drama']
  283. # akas---------------->
  284. # end copy/paste media_temp_list.txt
  285. # end of file example.py
  286. exit()
  287.