python-3.6

How to check if video has been deleted or removed in youtube using python

安稳与你 提交于 2021-01-27 20:53:43
问题 i have a csv file where i have 1000 videos links . I want to check whether these videos still exists or they have been removed or deleted from YouTube. How can i do that in python? Please guide on this 回答1: You could use the Official Youtube API for Python. There's a similar question for this problem in Stackoverflow, but meant for PHP (check this reference). 回答2: I'm the author of the Video Link Checker plugin that does this for YouTube, DailyMotion, Vimeo, etc. I can't help with Python code

Using json model field with django graphene

帅比萌擦擦* 提交于 2021-01-27 18:04:01
问题 I'm working with graphql endpoint for my project. One of models has textfield which contains some json. If i request list of my entities via graphql, I'm getting this json like a string. How to reach ability to use it in graphql as nested structure with ability of filtering, choosing some properties etc. class SysObjects(models.Model): id = models.BigAutoField(primary_key=True) user_id = models.BigIntegerField() type_id = models.PositiveIntegerField(blank=True, null=True) # status = models

Using json model field with django graphene

陌路散爱 提交于 2021-01-27 17:19:43
问题 I'm working with graphql endpoint for my project. One of models has textfield which contains some json. If i request list of my entities via graphql, I'm getting this json like a string. How to reach ability to use it in graphql as nested structure with ability of filtering, choosing some properties etc. class SysObjects(models.Model): id = models.BigAutoField(primary_key=True) user_id = models.BigIntegerField() type_id = models.PositiveIntegerField(blank=True, null=True) # status = models

How do you have a Discord bot read DMs sent to it? (discord.py)

冷暖自知 提交于 2021-01-27 12:50:55
问题 I've come up with a way to DM people, but I want to know what they say back to the bot through DMs, as if the bot "reads" the DM, and then forwards it to some channel in a discord server of mine, or, even better, DM it to me. Here is my starting code: if message.content.startswith("!dm"): if message.author.id == "[YOUR ID HERE]": memberID = "ID OF RECIPIENT" server = message.server person = discord.Server.get_member(server, memberID) await client.delete_message(message) await client.send

Does a default parameters overwrite type hints for mypy?

不羁的心 提交于 2021-01-22 06:37:13
问题 The following code is rejected by mypy as expected: def foo(value: int) -> None: print(value, type(value)) foo(None) output: error: Argument 1 to "foo" has incompatible type "None"; expected "int" But after introducing a default parameter of None , there is no error anymore: def foo(value: int=None) -> None: print(value, type(value)) foo(None) I would expect mypy to only allow None (as argument and as the default) if we change value from int to Optional[int] , but it seems like this is not

cannot write mode RGBA as JPEG [duplicate]

筅森魡賤 提交于 2021-01-13 03:56:04
问题 This question already has answers here : Convert png to jpeg using Pillow (4 answers) Closed 2 years ago . I am learning to use 'pillow 5.0' following book 'Automate the boring stuff with python' The info about the image object In [79]: audacious = auda In [80]: print(audacious.format, audacious.size, audacious.mode) PNG (1094, 960) RGBA When I tried to convert filetype, it report error. In [83]: audacious.save('audacious.jpg') OSError: cannot write mode RGBA as JPEG There's no such a n error

cannot write mode RGBA as JPEG [duplicate]

五迷三道 提交于 2021-01-13 03:53:29
问题 This question already has answers here : Convert png to jpeg using Pillow (4 answers) Closed 2 years ago . I am learning to use 'pillow 5.0' following book 'Automate the boring stuff with python' The info about the image object In [79]: audacious = auda In [80]: print(audacious.format, audacious.size, audacious.mode) PNG (1094, 960) RGBA When I tried to convert filetype, it report error. In [83]: audacious.save('audacious.jpg') OSError: cannot write mode RGBA as JPEG There's no such a n error

unittest unable to import class from pickle (AttributeError: Can't get attribute…)

落爺英雄遲暮 提交于 2021-01-05 11:35:33
问题 I need a unittest to load a previously saved class in a pickle. However, when I load the pickle in the unittest (out of unittest works), it raises the error: AttributeError: Can't get attribute 'Foo' on <module 'unittest. main ' from '...\unittest\ main .py'> Code example to save the class (I save this code in run_and_save_class.py ): from pickle import dump from pickle import load from pickle import HIGHEST_PROTOCOL class Foo(object): def __init__(self): self.bar = None self.file_out = ".

SpeechRecognition producing OSError: No Default Input Device Available

大兔子大兔子 提交于 2021-01-04 07:17:57
问题 This: import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source: print("Speak Anything :") audio = r.listen(source) try: text = r.recognize_google(audio) print("You said : {}".format(text)) except: print("Sorry could not recognize what you said") Producing this: Traceback (most recent call last): File "magic.py", line 5, in <module> with sr.Microphone() as source: File "/home/myPorfile/anaconda3/envs/customEnv/lib/python3.6/site-packages/speech_recognition/__init__.py

SpeechRecognition producing OSError: No Default Input Device Available

我只是一个虾纸丫 提交于 2021-01-04 07:17:02
问题 This: import speech_recognition as sr r = sr.Recognizer() with sr.Microphone() as source: print("Speak Anything :") audio = r.listen(source) try: text = r.recognize_google(audio) print("You said : {}".format(text)) except: print("Sorry could not recognize what you said") Producing this: Traceback (most recent call last): File "magic.py", line 5, in <module> with sr.Microphone() as source: File "/home/myPorfile/anaconda3/envs/customEnv/lib/python3.6/site-packages/speech_recognition/__init__.py