Open vanshikaarora opened 5 years ago
For working on this I have gone through the web page and the API'S. Whereby I found that this feature can be implemented just like on the website.
@maskaravivek @nicolas-raoul @misaochan @neslihanturan Kindly share your opinion regarding this :)
"Media of the day" could be added just before the featured pictures that appear when you open "Explore", good idea.
The categories system is being slowly replaced with the Structured Commons system, so I don't think investing much time developing new category browsing features should be our priority. In a few weeks I will submit an issue for adding Structured Commons properties when uploading, that will be a big task (big enough for a GSoC for instance) and make more sense to implement. I will try to think of a similar top-down browsing UI within Structured Commons.
The categories system is being slowly replaced with the Structured Commons system, so I don't think investing much time developing new category browsing features should be our priority. In a few weeks I will submit an issue for adding Structured Commons properties when uploading, that will be a big task (big enough for a GSoC for instance) and make more sense to implement. I will try to think of a similar top-down browsing UI within Structured Commons.
Structured Commons System would definitely be better indeed :)
"Media of the day" could be added just before the featured pictures that appear when you open "Explore", good idea.
For this In the documentation is see the API for fetching Media of the day.
So shall I create a separate issue for this or work in the same?
"Media of the day" could be added just before the featured pictures that appear when you open "Explore", good idea.
@nicolas-raoul Shall I add the "Media of the day" along with "Featured pictures" in a heterogeneous RecyclerView Or Should I create a separate tab for "Media of the day"
No need to create a separate tab, I think. Most people don't need to know how the pics are selected. They are just nice and interesting pictures.
@nicolas-raoul So shall I add two horizontal recyclerViews?
Sorry I don't know what is the best way to implement that in Android :-/
Sorry I don't know what is the best way to implement that in Android :-/
@nicolas-raoul we need to have more suggestions then regarding the UI part :)
@maskaravivek @neslihanturan @misaochan Can you please pitch in your ideas :)
I suggest using the same view as now, but simply feeding a mix of pictures from different sources into it:
Ohh so is it like alternate media of the day as well as pictures of the day?
The images currently shown are the latest added pictures of this category: https://commons.wikimedia.org/wiki/Category:Featured_pictures I believe.
The images currently shown are the latest added pictures of this category: https://commons.wikimedia.org/wiki/Category:Featured_pictures I believe.
@nicolas-raoul Yes, the images currently fetched are the featured images from the API https://commons.wikimedia.org/w/api.php?action=help&modules=featuredfeed
Currently it fetches the images by setting feed =potd, on setting feed =motd we can fetch media of the day. So is it to be set in the same view as the current featured images.
Please correct me if there is any difference in opinion :)
Currently it fetches the images by setting feed =potd, on setting feed =motd we can fetch media of the day. So is it to be set in the same view as the current featured images.
Yes, we can show it in the same view. :)
Yes, we can show it in the same view. :)
Since we have multiple upvotes for the same. Then I'll start working on this and add it to the same Recycler view with alternating potd and motd.
@maskaravivek @nicolas-raoul Can you please let me know
@Override
@Nullable
public Single<Media> getMediaOfTheDay() {
return Single.fromCallable(() -> {
CustomApiResult apiResult = null;
try {
String template = "Template:Potd/" + DateUtils.getCurrentDate();
CustomMwApi.RequestBuilder requestBuilder = api.action("query")
//.param("generator", "media")
.param("format", "xml")
.param("prop", "imageinfo")
.param("iiprop", "url|extmetadata");
apiResult = requestBuilder.get();
} catch (IOException e) {
Timber.e(e, "Failed to obtain searchCategories");
}
if (apiResult == null) {
return null;
}
CustomApiResult imageNode = apiResult.getNode("/api/query/pages/page");
if (imageNode == null
|| imageNode.getDocument() == null) {
return null;
}
return CategoryImageUtils.getMediaFromPage(imageNode.getDocument());
});
}
is this the current api request that I am making?
This will fetch only one image. Instead use
https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&format=json
This will fetch only one image. Instead use
https://commons.wikimedia.org/w/api.php?action=featuredfeed&feed=potd&format=json
@maskaravivek I tried to use this API but the response returned is in XML format. Can I recieve the response in JSON format?
Nope, unfortunately, this API ignores the XML response.
https://www.mediawiki.org/wiki/API:Showing_interesting_content#How_it_works_on_Wikimedia_wikis
@maskaravivek I tried using this for the API:
CustomMwApi.RequestBuilder requestBuilder = api.action("featuredfeed")
.param("feed","potd")
.param("format","json");
But the result returned was:
Is it something wrong with the API call?
Is it not working?
Can you share the full API response from logcat?
I have recieved the following in my debug logs
You are sending format
param twice. Am not sure if that is causing the issue. Rest of the request looks fine.
According to the response, potd
value is not valid.
You are sending
format
param twice
@maskaravivek I have modified this error but still I got an invalid respose from the API. with an error code="unknown_feed"
.
You are using the beta app. Can you check on prod environment? It's possible that beta server doesn't have this feed
@maskaravivek Here is the reponse in prod environment:
The response doesn't returns an error code="unknown_feed"
but yet it isn't the one expected the title in the information obtained isn't the title of my self-uploaded image
The response looks correct but you might need to parse it differently. Can you compare the responses for category images and this feed and find the differences.
@maskaravivek Here is the response for category images both are pretty similiar
The parsing for CategoryList is done with
CustomMwApi.RequestBuilder requestBuilder = api.action("query")
.param("generator", "categories")
.param("format", "xml")
.param("titles", categoryName)
.param("prop", "info")
.param("cllimit", "500")
.param("iiprop", "url|extmetadata");
while for motd I have added
CustomMwApi.RequestBuilder requestBuilder = api.action("featuredfeed")
.param("feed","potd");
Can you compare the responses for category images and this feed and find the differences.
Should I use the same code for parsing mediaoftheday as of categorylist?
@maskaravivek I have modified the code and now I am using the following for receiving response
api.action("featuredfeed")
.param("format","json")
.param("feedformat","rss")
.param("feed","motd")
.get()
.getNode("rss/channel/item/description").getDocument().getFirstChild().getNodeValue();
The response generated is as follows:
<div class="mw-parser-output"><div class="floatright">
<table class="toccolours" style="width:300px;text-align:center">
<tbody><tr>
<th lang="en"><a href="/wiki/Commons:Media_of_the_day" title="Commons:Media of the day">Media of the day</a>
</th></tr>
<tr>
<td class="toccolours" style="padding:0"><div id="mwe_player_0" class="PopUpMediaTransform" style="width:300px;" videopayload="<div class="mediaContainer" style="width:854px"><video id="mwe_player_1" poster="https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/Prague_2018-04-19.webm/854px--Prague_2018-04-19.webm.jpg" controls="" preload="none" autoplay="" style="width:854px;height:480px" class="kskin" data-durationhint="33.069" data-startoffset="0" data-mwtitle="Prague_2018-04-19.webm" data-mwprovider="local"><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.480p.webm" type="video/webm; codecs=&quot;vp8, vorbis&quot;" data-title="SD WebM (480P)" data-shorttitle="WebM 480P" data-transcodekey="480p.webm" data-width="854" data-height="480" data-bandwidth="880752" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.480p.vp9.webm" type="video/webm; codecs=&quot;vp9, opus&quot;" data-title="SD VP9 (480P)" data-shorttitle="VP9 480P" data-transcodekey="480p.vp9.webm" data-width="854" data-height="480" data-bandwidth="1367936" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.720p.webm" type="video/webm; codecs=&quot;vp8, vorbis&quot;" data-title="HD WebM (720P)" data-shorttitle="WebM 720P" data-transcodekey="720p.webm" data-width="1280" data-height="720" data-bandwidth="1618600" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.720p.vp9.webm" type="video/webm; codecs=&quot;vp9, opus&quot;" data-title="HD VP9 (720P)" data-shorttitle="VP9 720P" data-transcodekey="720p.vp9.webm" data-width="1280" data-height="720" data-bandwidth="2635144" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.1080p.webm" type="video/webm; codecs=&quot;vp8, vorbis&quot;" data-title="Full HD WebM (1080P)" data-shorttitle="WebM 1080P" data-transcodekey="1080p.webm" data-width="1920" data-height="1080" data-bandwidth="3743848" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.1080p.vp9.webm" type="video/webm; codecs=&quot;vp9, opus&quot;" data-title="Full HD VP9 (1080P)" data-shorttitle="VP9 1080P" data-transcodekey="1080p.vp9.webm" data-width="1920" data-height="1080" data-bandwidth="5181312" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/7/79/Prague_2018-04-19.webm" type="video/webm; codecs=&quot;vp8, vorbis&quot;" data-title="Original WebM file, 1,920 × 1,080 (14.02 Mbps)" data-shorttitle="WebM source" data-width="1920" data-height="1080" data-bandwidth="14020590" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.120p.vp9.webm" type="video/webm; codecs=&quot;vp9, opus&quot;" data-title="Lowest bandwidth VP9 (120P)" data-shorttitle="VP9 120P" data-transcodekey="120p.vp9.webm" data-width="214" data-height="120" data-bandwidth="208120" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.160p.webm" type="video/webm; codecs=&quot;vp8, vorbis&quot;" data-title="Low bandwidth WebM (160P)" data-shorttitle="WebM 160P" data-transcodekey="160p.webm" data-width="284" data-height="160" data-bandwidth="203248" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.180p.vp9.webm" type="video/webm; codecs=&quot;vp9, opus&quot;" data-title="Low bandwidth VP9 (180P)" data-shorttitle="VP9 180P" data-transcodekey="180p.vp9.webm" data-width="320" data-height="180" data-bandwidth="301504" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.240p.webm" type="video/webm; codecs=&quot;vp8, vorbis&quot;" data-title="Small WebM (240P)" data-shorttitle="WebM 240P" data-transcodekey="240p.webm" data-width="426" data-height="240" data-bandwidth="332296" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.240p.vp9.webm" type="video/webm; codecs=&quot;vp9, opus&quot;" data-title="Small VP9 (240P)" data-shorttitle="VP9 240P" data-transcodekey="240p.vp9.webm" data-width="426" data-height="240" data-bandwidth="420560" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.360p.webm" type="video/webm; codecs=&quot;vp8, vorbis&quot;" data-title="WebM (360P)" data-shorttitle="WebM 360P" data-transcodekey="360p.webm" data-width="640" data-height="360" data-bandwidth="562368" data-framerate="29.97"/><source src="https://upload.wikimedia.org/wikipedia/commons/transcoded/7/79/Prague_2018-04-19.webm/Prague_2018-04-19.webm.360p.vp9.webm" type="video/webm; codecs=&quot;vp9, opus&quot;" data-title="VP9 (360P)" data-shorttitle="VP9 360P" data-transcodekey="360p.vp9.webm" data-width="640" data-height="360" data-bandwidth="726688" data-framerate="29.97"/></video></div>"><img alt="File:Prague 2018-04-19.webm" style="width:300px;height:169px" src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/79/Prague_2018-04-19.webm/300px--Prague_2018-04-19.webm.jpg" /><a href="https://upload.wikimedia.org/wikipedia/commons/7/79/Prague_2018-04-19.webm" title="Play media" target="new"><span class="play-btn-large"><span class="mw-tmh-playtext">Play media</span></span></a></div>
</td></tr>
<tr>
<td><div lang="en" class="description en" style="display:inline;">View of <a href="https://en.wikipedia.org/wiki/Old_Town_Square" class="extiw" title="w:Old Town Square">Old Town Square</a> in <a href="/wiki/Prague" class="mw-redirect" title="Prague">Prague</a>. </div> 
<hr />
<div lang="en" class="description en" style="display:inline;"><a href="/wiki/Commons:Media_help" title="Commons:Media help">Problems playing the file?</a></div>
</td></tr></tbody></table>
</div>
</div>
This contains the Url for the images, the next thing in hand is how to parse these Url's one way that I have found after searching is writing Regex but it is it the best solution or there is some other way too. @maskaravivek @nicolas-raoul Can you please ive your suggestions on how to parse this Url?
IMO, regex would be the best option. Another option is to use jsoup but it would require adding a library. Am not in favor of adding a library just for one small parsing.
I somehow feel that a lot of time and effort is going into this task. It might be okay to take a break from this task if you feel you can invest your time in other more fruitful tasks. It's your choice. :)
Summary: Explore fragment currently is used for featured Images Unlike Wikimedia commons website main page includes both category and Images we can add the same feature in our app's explore fragments for featured category.
How to add this feature?
The explore fragment can contain two tabs one for featured Images the other for featured categories. Which will have list of the featured categories fetched from API
Would you like to work on the issue? Yes