I have a medialibrarypickerfield, I've added a youtube video to it.
How can I get access to the YouTube video URL in an alternate at the following level:
MediaLibraryPicker-ContentType-VideoFieldName.cshtml
I've tried
var field = (MediaLibraryPickerField) Model.ContentField;
var contents = field.MediaParts;
to gain access to each MediaPart/video but when I iterate through the MediaParts, the MediaUrl is null. I know this has something to do with the OEmbedPart but I don't know how to access this.
Extremely frustrating so far. An otherwise very simple task outside of Orchard to store and retrieve URLs.
To access the oEmbed part, just do As<OEmbedPart>() on the media part. You can then access the URL for the video by using the Source property of the part. You can also access a number of properties that are provided by the oEmbed site (YouTube in your case). Those properties can be accessed using the indexer on the part.
For example, part["html"] will give you the html code to embed in your page to render the video player:
#Html.Raw(part["html"])
There is also a "thumbnail" or a "thumbnail_url" property (depending on provider) that will give you the url of a thumbnail image. You can look at the whole blob of XML underlying that in the Framework_ContentItemRecord table's Data column. There is also a width and a height for example.
Related
I use ACF as a placeholder for a bunch of videos on my WordPress-Website. I embed them from Vimeo via oembed.
The only thing is: Vimeo offers a function called "background". It's usually attached to the URL like this: https://player.vimeo.com/video/{Video-ID}?background=1
Unfortunately, the appendage after the Video-ID is ignored by ACF oembed, in the iframe, there is only the URL of the video without the "Background"-attachment.
I hope you can help to make ACF oembed accept the whole URL incl. Appendage.
Thanks, best, Roman
PS: There is a page of ACF with some Code to display value with additional attributes. https://www.advancedcustomfields.com/resources/oembed/
I put some PHP-Code into the functions-PHP of my WordPress-Account.
But unfortunately, nothing worked.
I've recently made a Python program using the Youtube api v3 where, given a playlist id, it fetches certain information from every video in the playlist. However, through both the output of this code and this post on Google, it's pretty clear that information on videos that were either privated or deleted is not available through the Youtube api.
Is there an alternative program or resource that I can use to extract information from these unavailable videos, in particular their video ids?
The only solution I can think of now is to access the HTML of the display Youtube and search through it for certain strings (like "[deleted video]") and to then extract the id corresponding to that string. But, I've never dealt with HTML and, if I understand HTML correctly, I'd have to load a new page for every 50 videos in the playlist, which for playlists with thousands of videos, becomes rather inefficient and laborious.
I was hoping to use something like PyTube, but that couldn't handle unavailable videos either.
Edit
Here is the code that extracts the video ids:
from googleapiclient.discovery import build
api_key = "AI~~~" #get from yt (private key)
yt = build("youtube", "v3", developerKey = api_key)
plst_id = "PLorw3mfu-J0ipF4Ss0XgR8IxcwP-JzNKC" #unique yt playlist id
plst_req = yt.playlistItems().list( #request for info from yt api
part = "contentDetails",
playlistId = plst_id,
maxResults = 50
)
plst = plst_req.execute()
vid_ids = [] #available video ids taken from current playlist
for vid in plst['items']:
vid_ids.append(vid['contentDetails']['videoId'])
print(vid_ids)
print(plst['pageInfo']['totalResults'])
The first line printed contains the video ids of every available video in the playlist. The second line printed gives the number of videos in the playlist, including available and unavailable ones.
The playlist used in the code above is given here. It contains 10 total videos, of which one of them is unavailable.
In this case, the output is (with a valid api key)
['bv_cEeDlop0', 'mRKTOZmX2cE', '5ACvKdx1nns', 'wSNhP8b_Avo', 's56cHgokPlE', 'E4IHMWnQiMw', 'sCDkPShADSc', 'EVwgeUVVDYU', 'Z8Mqw0b9ADs']
10
Youtube still treats unavailable videos as an element of the playlist, but does not give out it's video id. In this particular instance, the video id of the unavailable video is "t83zUmjr05I", which is not hard to find manually: copy the link address of the deleted video and extract the part after the "v=".
But, on a larger scale manual extraction becomes tedious.
Here's a permanent fix to that!
You can try tube_dl.
pip install tube_dl
It uses modular approach and is up to date
More about this can be found at : https://github.com/shekharchander/tube_dl/
Maybe, the playlist module can help you with that. It uses regex to grab all video IDs not JSON. Please let me know if the problem is fixed or not, I will update module accordingly.
Edit
Here's the working code
from tube_dl import Playlist
p = Playlist('https://youtube.com/playlist?list=PLorw3mfu-J0ipF4Ss0XgR8IxcwP-JzNKC').videos
print(p)
I have two "Live streaming/live broadcast saved playlists" in following youtube channel --> https://www.youtube.com/user/swaminarayanlive.
I am trying to retrieve all the "live streaming / live broadcast playlists" of a channel using new youtube v3 api by using the below link-->
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCBkNpeyvBO2TdPGVC_PsPUA&key={YOUR_API_KEY}
here i can get the info of playlists which are not live streams or live broadcast. and not able to get the same for the live one.
Please help me how can i get that for live one using youtube v3 api
I was researching another issue with the API when finding this, and when I saw that this was never resolved, I decided to look into it. It turns out that this is related to that other issue.
The YouTube API v3 lacks support for saved playlists. The channel swaminarayanlive did not create the playlists, only saved them from the channel BhujMandir.
The workaround in your case would be to retrieve the playlists of BhujMandir and extract the response snippets with "title" parameters containing the word "Live".
You would need to go through the pages and search each one for this, since there is a limit to how many results an API response can show at once. Currently it's 50.
So, you would use the following to get the first page of playlistItems:
GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCVItNtUctAknegvmYcMhUQg&maxResults=50&key={YOUR_API_KEY}
This will return an API response containing the properties "kind" (which will have the value "youtube#playlistListResponse") and "etag". If there are more than 50 results, there will also be a "nextPageToken" property. (On a page that is not the first, there would also be a "prevPageToken" property.)
After these properties, there are two blocks. One called "pageInfo", containing info about how many results (playlists) there are and how many are shown per page, and one block called "items", containing the resulting playlistItems.
You would look through the items block for any playlistItem with a title property (which is a string) containing the substring "Live" and get the id properties of those. You would then look on the next page by using the nextPageToken's value in a new HTTP request, like so:
GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCVItNtUctAknegvmYcMhUQg&maxResults=50&pageToken=[nextPageToken_value_here]&key={YOUR_API_KEY}
As of now, the two playlists you're looking for are on the pages with tokens CJYBEAA and CMgBEAA.
I think that where is the {YOUR_API_KEY} you should change this code and insert the name of your application program interface
This is my Volusion item insert method, which relies on the HTTParty gem for rails. It works for posting items without photos, and posting items with a single photos by using the <PhotoURL_Large> and <PhotoURL_Small> XML tags.
def self.post_volusion_item(hide_product, product_code, product_name, product_description, availability, custom_field1, custom_field2, enable_options_inv_control, free_shipping_item, height, length, width, metatag_description, metatag_title, photo_alt_text, photo_xml, product_category, product_price, product_weight, metatag_keywords)
encrypted_password = ENV['VOLUSION_PASSWORD']
post_url = "https://WEBSITE-HERE/net/WebService.aspx?Login=LOGIN-HERE&EncryptedPassword=#{encrypted_password}&Import=Insert"
body = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Volusion_API><Products><HideProduct>#{hide_product}</HideProduct><ProductCode>#{product_code}</ProductCode><ProductName>#{product_name}</ProductName><ProductDescription>#{product_description}</ProductDescription><Availability>#{availability}</Availability><CustomField1>#{custom_field1}</CustomField1><CustomField2>#{custom_field2}</CustomField2><EnableOptions_InventoryControl>#{enable_options_inv_control}</EnableOptions_InventoryControl><FreeShippingItem>#{free_shipping_item}</FreeShippingItem><Height>#{height}</Height><Length>#{length}</Length><Width>#{width}</Width><METATAG_Description>#{metatag_description}</METATAG_Description><METATAG_Title>#{metatag_title}</METATAG_Title><Photo_AltText>#{photo_alt_text}</Photo_AltText><PhotoURL_Large>#{photo_url_large}</PhotoURL_Large><PhotoURL_Small>#{photo_url_small}</PhotoURL_Small><ProductCategory>#{product_category}</ProductCategory><ProductPrice>#{product_price}</ProductPrice><ProductWeight>#{product_weight}</ProductWeight><METATAG_Keywords>#{metatag_keywords}</METATAG_Keywords></Products></Volusion_API>"
post(post_url, body: body)
end
I can not find any documentation that gives an example with multiple photos in the item. I have tried duplicating the calls. Example: <PhotoURL_Large>img1</PhotoURL_Large><PhotoURL_Small>img1</PhotoURL_Small><PhotoURL_Large>img2</PhotoURL_Large><PhotoURL_Small>img2</PhotoURL_Small>
This resulted in no images uploading.
I am realizing the the PhotoURL is not related to the urls of the item's photos, but only tied to the data in Volusion's add item form.
Can someone point me in the right direction for accessing the true photo urls for volusion items?
In Volusion, PhotoURL_Small and PhotoURL_Large are alternate image URLs that can either point to an internal or external location. Volusion only provides one of each for each product code which will be used by the product in place of any loaded image. So if you populate any of the above two fields for that product it will use that URL in place of any image uploaded via the image manager or any images directly uploaded via FTP. There is no provision in the software for additional PhotoURL_Small and PhotoURL_Large images.
Here is an excellent explanation of image file structure.
Image structure
I was using playlistitems to get the authenticated users' video list (including private/unlisted).
Now I tried contentOwnerId. I can get private video info using onBehalfOfContentOwner, but there is no onBehalfOfContentOwner key for playlistitems.
Is there other way to get the full list of an owned channel?
I'm fairly certain that the expected way of doing this is via search.list(part=snippet, forContentOwner=true, onBehalfOfContentOwner=CONTENT_OWNER_ID, type=video, maxResults=50) and optionally including channelId=UC... if you just want to get the videos in a specific channel you manage. You'd have to request multiple pages if there are more than 50 videos. I just tested that out and it does appear to return private as well as public videos.
Yes, it's kind of odd that this is done via search.list() and not playlistItems.list()...