mediathekview / mediathekviewweb

Eine Weboberfläche als Alternative zum Java-Client
https://mediathekviewweb.de/
GNU General Public License v3.0
897 stars 67 forks source link

Use at least the title shown on left side (maybe via DOM) for a better filename when saving.. #126

Open bufemc opened 5 years ago

bufemc commented 5 years ago

I've read the notes under: https://github.com/mediathekview/mediathekviewweb/issues/19

However, isn't it possible just to re-use the title shown on the left side (maybe via DOM) at least to give the file a meaningful name when saving it?

Example: Tatort: Murot und das Murmeltier

will be saved just as: 1280-1_357141.mp4

I think we all agree that a harddisk full of files named like this are quite a puzzle ;-)

Proposal, should be possible maybe by accessing DOM elements?:

  1. take/retrieve/transport the name shown on left side (via DOM?)
  2. replace illegal characters, like ":" with "-", " -" or "", result could be something like: Tatort - Murot und das Murmeltier - 1280-1_357141.mp4
Nicklas2751 commented 5 years ago

And how should we rename a file which isn‘t on our servers? I think you got that wrong, we have access to the metadata like the Title but not the video files. The video files are only on the servers of the Öffentlich Rechtliche and their Mediatheken.

G710 commented 5 years ago

You can actually download a file and replace the original name with something else via javascript. I once did this for a project. The code looked like this:

axios({
  url: 'http://exampleurl.com/file',
  method: 'GET',
  responseType: 'blob', // important
}).then((response) => {

  const url = window.URL.createObjectURL(new Blob([response.data], {type:'application/vnd.ms-excel'}));
  const link = document.createElement('a');

  link.href = url;
  link.setAttribute('download', 'NewFileName.xls');
  document.body.appendChild(link);
  link.click();
});

I used axios but it should also work with your run-of-the-mill XHR Request or whichever fetching mechanism you guys use. The important part is in the promise.

bagbag commented 5 years ago

I've had a similar idea for converting HLS streams into useful files. Great idea to use that for normal downloads too, thank you!