worldcompany / djangoembed Goto Github PK
View Code? Open in Web Editor NEWrich media consuming and providing with django
Home Page: http://djangoembed.readthedocs.org
License: MIT License
rich media consuming and providing with django
Home Page: http://djangoembed.readthedocs.org
License: MIT License
I have PIL installed but the import Image
is failing for me. Perhaps this should use something similar what Django did here: http://code.djangoproject.com/changeset/12429. Apparently PIL can be installed in different but incompatible ways?
Hello
I'm using oembed on my site to include Youtube videos. Problem is that my site includes navigation and the video if always on top. Solution is to include wmode=opaque in url.
Solution was to modify StoredProvider to http://api.embed.ly/v1/api/oembed?wmode=opaque but checking the code, in providers.py on line 113, url is built by joining parts with ?. With my new provider this does not work.
Could you please modify the code and correctly build url?
running 'manage.py syncdb' after install djangoembed fails with errors (abridged):
for (app_name, error) in get_app_errors().items():
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/db/models/loading.py", line 83, in load_app
if not module_has_submodule(app_module, 'models'):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/utils/module_loading.py", line 14, in module_has_submodule
for entry in package.path: # No path, then not a package.
AttributeError: 'module' object has no attribute 'path'
Python version: 2.7
Unlike previous issue filed against this code, my djangoembed egg has a fixtures directory. Any help appreciated.
Line#47. Change:
width --> w
height --> h
I changed the regex and wild-card fields in the admin, successfully once before, but when I re-synced my project they were overwritten by the old stuff. Any clue on what the new urls would be?
I've tried these with no success:
regex: http://twitter.com/%23!/*/status/*
wild-card: http://twitter.com/#!/*/status/*
Calling the SoundCloud endpoint with minimal parameters returns a width="100%" in the response. For example http://soundcloud.com/oembed?url=http://soundcloud.com/ghing/the-calling-for-diychi-comp&format=json produces this response:
{
"version": 1,
"type": "rich",
"provider_name": "SoundCloud",
"provider_url": "http://soundcloud.com",
"height": 166,
"width": "100%",
"title": "The Calling (for DIYCHI comp) by ghing",
"description": "Finished version of \"The Calling\" for the DIY CHI comp",
"html": "<iframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F27467434&show_artwork=true\"></iframe>"
}
I'm not sure whether or not this adheres to the oEmbed spec, but it's a popular service, so it should be handled.
The problem is in these lines in OEmbedResource.create():
data['width'] = data.get('width') and int(data['width']) or None
data['height'] = data.get('height') and int(data['height']) or None
the call to int(data['width']) raises a ValueError because of the '%' in data['width']
A simple workaround would be to wrap those lines in a try/except like this:
try:
data['width'] = data.get('width') and int(data['width']) or None
except ValueError:
data['width'] = None
try:
data['height'] = data.get('height') and int(data['height']) or None
except ValueError:
data['height'] = None
Currently the resize method of DjangoProvider raises an exception if the
image field is not a ImageFieldFile. However this requirement is used only
to get images heigth and width, and in the same function is already the
code to get those fields with PIL.
With this patch any FileField-like field could be used;
sorl.thumbnail.fields.ImageField for example. (I pasted the patch directly
since didn't find a way to attach files).
diff --git a/oembed/providers.py b/oembed/providers.py
index 58f4399..faf8d4c 100644
--- a/oembed/providers.py
+++ b/oembed/providers.py
@@ -459,13 +459,11 @@ class DjangoProvider(BaseProvider):
the url to the new image and the new width & height
(http://path-to-new-image, 300, 300)
"""
- if not isinstance(image_field, ImageFieldFile):
- raise ValueError('image_field must be an instance of django.db.models.fields.files.ImageFieldFile')
-
- if image_field.field.width_field and image_field.field.height_field:
- # use model fields
- current_width = getattr(image_field.instance, image_field.field.width_field)
- current_height = getattr(image_field.instance, image_field.field.height_field)
+ if isinstance(image_field, ImageFieldFile):
+ if image_field.field.width_field and image_field.field.height_field:
+ # use model fields
+ current_width = getattr(image_field.instance, image_field.field.width_field)
+ current_height = getattr(image_field.instance, image_field.field.height_field)
else:
# use PIL
try:
perhaps I did not get everything but I tested Slideshare : working
I tried to modify the endpoint to use the official one, took the URL from Slideshare site
http://www.slideshare.net/api/oembed/2
But this doesn't work (the endpoint returns XML)
Is this app tied to embedly specific flow ?
Hi,
thanks for this job. I just tested it wis something like this:
{{twitter_url|oembed}}
And the URL is get back, I suppose oembed do something weird.
I'm using Django 1.1.2 with MySQL, how to manually load the providers?
EDIT: I used pip to install djangoembed from source (git+http://...), and for some reason it didn't download the fixtures dir, so this is solved.
see http://help.youtube.com/group/youtube-howto/browse_thread/thread/3c342f54c33af012/2b8a08de12384900
if I´m using something like
http://www.youtube.com/watch?v=9bBkEQYdMM8&showinfo=0
the titles are still there.
not sure if that´s a djangoembed-issue though.
thanks,
patrick
I got this error when I tried syncdb:
_mysql_exceptions.OperationalError: (1170, "BLOB/TEXT column 'match' used in key specification without a key length")
To solve the problem i removed 'match' from the StoredOEmbed unique_together Meta.
Currently it's very difficult (if not impossible) to use djangoembed with
any markup format. I'm using restructured text, with the same goes for
textile, markdown, etc.
The big problem is that in markup rich text all links are enclosed in a "a"
element, so djangoembed never changes those links.
It would be great if I could set OEMBED_STRIP_LINKS=True
or something
like that in django settings.
I have played a bit with the code and could send a patch or pull request
for this, but I'm not very confident with my proposal. Maybe there's a
better way to get this working?
Using embed.ly as an endpoint is really cool, but requires an api key. It will work, but after a while the response will be a 403:
403: Forbidden - Embedly has blocked your client ip. Sign up for an API key at http://embed.ly.
However, I don't see a way to supply an API key using djangoembed
When installing djangoembed with pip it installs an old version. And it's from before the dependencies were specified, so they do not get installed.
Could you update the pypi package? I saw that you wrote that the project is not maintained anymore, but it could be great if the pypy package at least reflected the latest code in the repo.
Youtube uses youtu.be as a URL shortener. I've added this and tested.
Some endpoints are set as un-active. They're still active, though.
https://github.com/worldcompany/djangoembed/blob/master/oembed/fixtures/initial_data.json
If a photo-url is added to a model that uses media aggregation and then that instance is edited to remove that url the linked media is not removed.
Dependencies aren't noted in INSTALL.txt or required by setup.py. In addition to the ones in pip_requirements.txt, I also had to install httplib2 and simplejson (could the Python2.6+ json be used if it is available?)
Hi,
I could be wrong here but just in case, I said I'd bring this to your attention.
At the end of the parse_data method of the HTMLParser where you call "replaceWith" on the matched url;
It appears that with the step from BeautifulSoup 3.2.0 to BeautifulSoup 3.2.1
the inserted html is now being entity encoded, thus breaking things.
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup("")
soup.insert(0, "<b>YAY</b>")
print unicode(soup)
The above under BS 3.2.0 printed:
`````` YAY```
Under BS 3.2.1 it prints:
<b>YAY</b>
I haven't had the time to dig an awful lot but the solution might be to create a BS representation of the replacement html and pass that to replaceWith.
Thanks,
Dave
anyone else getting an autoescape error when the oembed html is rendered in a template?
I'm testing with a youtube URL.
When my database table stores the actual iframe embed code, the video is shown in the template correctly.
However, if the database stores just the youtube URL, oembed shows the iframe embed code with ascii codes for the angle brackets and quotation marks.
How do I fix this?
Using the safe filter doesn't help: {{ post.body|safe|oembed }}
Neither does using {% autoescape off %}
Might this be an error using beautifulsoup v.3 instead of beautifulsoup v.4?
Or might implementing mark_safe() help? https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#filters-and-auto-escaping
http://dpaste.com/537543/ is the traceback
I am getting a template error when using OEmbed tags, which I believe is due to the behaviour of the mock_request() function in utils.py.
It seems that mock_request() does not add a user object to the request object when it runs the context processors, normally provided by django.contrib.auth.context_processors.auth. This means that context processors of other apps that depend on the existence of a user object throw an exception.
In my case I have django_messages installed, whose context processor requires a user object to be present on Request. When the template is rendered, I get:
Caught AttributeError while rendering: 'HttpRequest' object has no attribute 'user'
Documentation seems to have vanished.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.